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

 
 


Izzatie
how to insert checkbox value into database using jsp
1 Answer(s)      10 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>
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 Pages:
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
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
checkbox
checkbox  how to insert multiple values in database by using checkbox in jsp
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 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
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 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
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
JSP CheckBox
JSP CheckBox          JSP CheckBox is used to create a CheckBox in JSP... illustrate an elaborate example from 'JSP CheckBox'. To understand and grasp
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database....   dear sir or madam, i wont to How to Store Image Into The Database
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>
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...;tr><td colspan="2" align="center"><input type="submit" value="Send
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 insert date&time coloumn value in mssql - JDBC
how to insert date&time coloumn value in mssql  how to insert...; Hi friend, Code insert date and time in Database : <% int val=0... = "INSERT INTO file_tbl set file_date='"+strDateNew+"'"; //out.println(queryString
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 values - JSP-Servlet
insert values  How to insert values in the oracle database using JSP... page<html><head><title>Insert value in database</title><...;100%"> <h1><center>Insert value in Database<
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
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
PHP Insert Value
Insertion of data into table: We will study in this tutorial how to insert... default value earlier, Type: insert into student values ('name', 21, 'emp_id'); Now to insert values into table:   ii)    Using WAMP
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
How to check a checkbox - Struts
How to check a checkbox  Hello Community, How can i check a checkbox... setting the checked attribute of a checkbox to true/checked when using the tags... please help me with the syntax??  Hi friend, my checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
To Upload and insert the CSV file into Database
to upload a CSV file through JSP and insert it into the database. For this, we have... To Upload and insert the CSV file into Database... = pst.executeUpdate("insert into file(file_data) values('"+value
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();"> <
insert into statement in sql using servlets
insert a value from a html form in the table stored in the database. ... insert into statement in sql using servlets   ... we are going to insert the values. Now make one jsp page or  html page
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
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 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
To Upload and insert the file into Database with Current Date and Time In JSP
; In this tutorial, you will learn how to upload a file through JSP and insert it into the database. For this, we have created two jsp pages page.jsp... To Upload and insert the file  into Database with Current Date
checkbox selection in jsp
checkbox selection in jsp  hey guys i am working on a web based project using jsp. In my project i am having 9 check boxes in 3 rows in the same... check box in the same row. How can i get this one working? Can anyone help me
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 insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
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
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
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
inserting value - JSP-Servlet
;Inserting form data into database using JSP and ServletGiven code will illustrate you, how one can get data into database using JSP and ServletExample Code... that will insert the HTML form data into database using JSP and Servlet
How to insert multiple checkboxes into Msaccess database J2EE using prepared statement - Java Beginners
How to insert multiple checkboxes into Msaccess database J2EE using prepared... statement to do the checked boxes part, I'm not sure how to go about doing..."); int subjects = strSubjects.length; strCreateRecordSQL = "INSERT INTO Parents
what is the jsp coding to insert a data in database tables
what is the jsp coding to insert a data in database tables  Dear Sir, I Want to know the coding for insert the data from jsp to oracle database.. my... that insert the form values to MySQL database. 1)register.jsp: <html> <form
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
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it   I have tried the following code Database creation: create database studentdb; create table stu_info ( ID int not null auto
Insert file data into database
Insert file data into database In this section, you will learn how to insert.... Now to insert this data into the database, we have established a database connection. Then using the insert query, we have inserted whole file data
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.