Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to insert checkbox value into database using jsp

Have Programming Question? Ask it here!
 
 
 


Izzatie
how to insert checkbox value into database using jsp
1 Answer(s)      a year and 9 months ago
Posted in : Java Beginners


How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I also have the ACTIVITY table, where it have the PK for every activities.

Here is my code

<%

String pack_id="";
Class.forName("oracle.jdbc.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:orcl", "myvgh", "myvgh");
try{
Statement statement=conn.createStatement();
ResultSet rs=statement.executeQuery("SELECT NVL(MAX(PACK_ID),0) + 1 FROM PACKAGE");
     while(rs.next()){
     pack_id = rs.getString(1);

                      }


  }catch(Exception e1)
  {}
  %> 

                <form>
                <table width="871" height="413" border="0">
                  <tr>
                  <tr>
                                                <td>&nbsp;</td>
                                                <td><input name="pack_id" type="type" value="<%= pack_id %>" size="3" readonly="readonly" /></td>
                                              </tr>
                <td width="124">
                          <p>Package Name</p></td>
                        <td width="29">:</td>
                        <td width="704">
                          <label for="pack_type"></label>
                          <input type="text" name="pack_type" id="pack_type" />
                      </td>
                      </tr>

                      <tr>
                        <td><p>Night and Day</p></td>
                        <td>:</td>
                        <td>
                          <label for="pack_day"></label>
                          <input type="text" name="pack_day" id="pack_day" />
                                          </td>
                      </tr>

                      <tr>
                        <td><p>Meal</p></td>
                        <td>:</td>
                        <td>
                          <label for="pack_meal"></label>
                          <input type="checkbox" name="pack_meal" id="breakfast" />Breakfast
                          <input type="checkbox" name="pack_meal" id="Lunch" />Lunch
                          <input type="checkbox" name="pack_meal" id="Dinner" />Dinner

                          </td>
                      </tr>

                      <tr>
                        <td><label for="activity8"> Activity<br />
                        </label></td>
                        <td>: </td>
                        <td><input name="activity7" type="checkbox" id="act_name" name="act_name" value="caltural_night" />
                        Cultural Night
                             <input name="activity" type="checkbox" id="act_name" name="act_name" value="batik_painting" />Batik Painting </td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td><input type="checkbox" id="act_name" name="act_name" value="pounding_rice" />Pounding Rice 
                          <input type="checkbox" id="act_name" name="act_name" value="fishing" />Fishing </td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td><input type="checkbox" name="act_name" id="act_name" value="kite_making" />
                        Kite Making
                           &nbsp; <input type="checkbox" id="act_name" name="act_name" value="gagau_ikan" />&quot;Gagau Ikan&quot;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td><input type="checkbox" id="activity12" name="act_name" value="iks_visit" />
                        IKS Visit
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                         <input type="checkbox" id="activity13" name="act_name" value="bbq" />BBQ</td>
                      </tr>
                      <tr>
                        <td>Price (RM)</td>
                        <td>:</td>
                        <td>
                          <label for="pack_price"></label>
                          <input name="pack_price" type="text" id="pack_price" size="12" />
                        </td>
                      </tr>
                      <tr>
                        <td>Max Person</td>
                        <td>:</td>
                        <td>
                          <label for="pack_max"></label>
                          <input name="pack_max" type="text" id="pack_max" size="7" />
                        </td>
                      </tr>
                      </table>
                      <div align="center">
                        <input type="submit" name="submit2" id="submit2" value="Submit" />
                        <input type="submit" name="clear2" id="clear2" value="Clear" />
                     </div></td>
                  </tr>
                  </table>
                  </form>

Advertisement
View Answers

July 12, 2012 at 5:08 PM


Here is a simple jsp code that insert the selected checkbox values into database.

1)checkbox.jsp:

<html>
<body>
<form method="post" action="insertmultiple.jsp" >
Select Languages:<br>
<input type="checkbox" name="lang" value="C/C++">C/C++<br>
<input type="checkbox" name="lang" value="JAVA">Java<br>
<input type="checkbox" name="lang" value="C#">C#<br>
<input type="checkbox" name="lang" value="PERL">PERL<br>
<input type="checkbox" name="lang" value="PYTHON">PYTHON<br>
<input type="submit" value="Submit">
</form>
</body>
</html>

2)insertmultiple.jsp:

<%@page import="java.sql.*"%>
<%
String languages="";
String lang[]=request.getParameterValues("lang");
for(int i=0;i<lang.length;i++){
    languages+=lang[i]+" ";
}

        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st=con.createStatement();
        int i=st.executeUpdate("insert into student(languages) values('"+languages+"')");
        out.println("Data is successfully inserted into database.");
        }
        catch(Exception e){
        System.out.println(e);

} %>



Related Tutorials/Questions & Answers:
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  how to insert check box value to the database using jsp my code is <link href...="center"> <input type="checkbox" name="pmanager" value="Edit
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's...;input name="activity7" type="checkbox" id="act_name" name="act_name" value
Advertisements
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's...;   Here is a simple jsp code that insert the selected checkbox values
insert data in the database using checkbox
insert data in the database using checkbox  i am fetching data from the database using servlet on the jsp page and there is checkbox corresponding... should i insert only checked data into database on submission.   We
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... and database name. Here machine name id localhost and database name..."; // declare a connection by using Connection interface
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
User Registration Form Using JSP(JspBeans) after that how i can insert in database
User Registration Form Using JSP(JspBeans) after that how i can insert in database   User Registration Form Using JSP(JspBeans) after that how i can insert in database
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I... i want is when the value in booking status is "booked" then the pictures shown as seats should be displayed red. when the value in booking status
How to change the checkbox value dynamically.
How to change the checkbox value dynamically.  Hi, I am using struts 1.2 checkbox tag. Requirement is on page load the value must be "true... the page. Then the checkbox is checked instead it have to show unchecked. And even
How to insert or delete records in MS access database using jsp - JSP-Servlet
How to insert or delete records in MS access database using jsp  Hi friends please provide me a solution that i insert or delete record from a database using java server pages. I used the microsoft access 2003 database. PlZ
insert checkbox in cell using POI api in java
insert checkbox in cell using POI api in java  I need to insert checkbox in excel cell using POI and java. Any one help me on this. Ashok S
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
how to update checkbox list in database
how to update checkbox list in database  Issues: i am using... in the database below logic is working fine by using insert command... to update one by one but it's not updating by using below code .it's not adding
how to insert multiple columns of a single row into my sql database using jsp
how to insert multiple columns of a single row into my sql database using jsp  hi sir, how to insert multiple columns of a single row into my sql database using jsp. when i click ADD ROW,rows are added.when i click submit
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which... be inserted into oracle database.. please help me sir...   hi friend
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  ... that dynamically generated text box value into database at a time without reloading the page what i want is i can insert the multiple columns value generated
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want...; } function showEmp(emp_value) { if(document.getElementById("emp_id").value
checkbox
checkbox  how to insert multiple values in database by using checkbox in jsp
Insert data in mysql database through jsp using prepared statement
; This is detailed jsp code that how to insert data into database by using prepared statement... Insert data in mysql database through jsp using prepared statement...; <HEAD> <TITLE>insert data using prepared statement </TITLE>
How to insert dynamic textbox values into database using Java?
How to insert dynamic textbox values into database using Java?  Hi I am trying to insert dynamic textbox values to database, my jsp form have 2... of dynamic textboxes with Name and Address will display....Now I want to Insert
insert name city image in database using mysql and jsp
insert name city image in database using mysql and jsp  how to insert name ,city and image in database in mysql and jsp   Here is an example in jsp that insert name, city and image to database. <%@ page import
how to delete the access database value in jsp
how to delete the access database value in jsp  i loaded my database data into the dropdown list box...now i want to delete the value..plz send the source code to delete the value in dropdown list box and also from database
how to delete the access database value in jsp
how to delete the access database value in jsp  i loaded my database data into the dropdown list box...now i want to delete the value..plz send the source code to delete the value in dropdown list box and also from database
how to insert data from database using oops concepts - Development process
how to insert data from database using oops concepts  Hi, How to insert data from database using oops based concepts.please write the code... the following code: import java.sql.*; class Insert{ public static String url
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
How to insert data from textfields into database using hibernate?
How to insert data from textfields into database using hibernate?   try{ Session session = HibernateUtil.getSessionFactory().openSession...); System.out.println("Successfully data insert in database"); tx.commit
deleting messages using checkbox in JSP
deleting messages using checkbox in JSP  Am working on a Mail Server...;input type="checkbox" name="inboxchk" value="<%=rs.getInt("omailid")%>">..." name="delete" value="Delete Mail" onClick="return ValidateForm();">
deleting messages using checkbox in JSP
deleting messages using checkbox in JSP  Am working on a Mail Server...;input type="checkbox" name="inboxchk" value="<%=rs.getInt("omailid")%>"><..." name="delete" value="Delete Mail" onClick="return ValidateForm();"> <
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to insert and retreive an image in mysql database using spring mvc framework???
How to insert and retreive an image in mysql database using spring mvc framework???  I ve solved this problem based on the Product Search Application. Those who need this concept and code segment kindly copy it. Thanks and All
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database. ... but was unable to find out exact way to fullfill the solution of selecting value from autocomplete textbox using jquery in jsp from mysql database. Kindly send me
How to Insert image and data both together in database in JSP/Servlet ?
How to Insert image and data both together in database in JSP/Servlet ? ..." value="Send File"> </td> </tr> <table> </center>... = connection.prepareStatement("insert into data(Name,City,Img) values('"+nn+"','"+cc
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use
To insert attachment file in database in JSP.
To insert attachment file in database in JSP.  I am doing project in JSP. How to insert attachment file in mysql database? Please suggest some solution. Your inputs is valuable to me.   Hi Friend, Visit Here Thanks
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box...... i already stored combo box values from database. pl
how to insert value in dynamic table
how to insert value in dynamic table  i am creating a project...=con.prepareStatement("insert into "+company+year+"(firstname,lastname,email... student table. and company and year value i'm getting through company table.but apache
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query...; Mysql database Table. Code to insert row in Mysql table : databaseinsertion.jsp
insert date into database using jsf
insert date into database using jsf  Hello I need a simple example of source code to insert a date into a database using jsf what do I have to put in backing bean and page jsf ( i need juste a date ) thanks
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends, When i click combobox value in jsp form page, it will diplay related value.... I am using only this page.. not get value from another page
checkbox value in php
checkbox value in php  In my HTML,PHP form ..we have a check box that is working fine. But anyhow i am not able to get the value of it. Can anyone suggest how to get the value of checkbox in PHP
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me... the following link: http://www.roseindia.net/jsp/comboSelect.shtml Hope
how to create database and table using jsp
how to create database and table using jsp  hi frnds...., i want to create database and table in mysql using jsp.... i have an registration form(name... table using jsp code... the table name should be the name of the person
how to show value and percentage in piechart sections from database using jfreechart
how to show value and percentage in piechart sections from database using jfreechart  Hii Sir, I made a pie chart from database using... Method /** * This method creates a test pie chart using internally
 

 

 

DMCA.com