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



Home Answers Viewqa Development-process Store combo box value

Have Programming Question? Ask it here!
 
 
 


Rajendra
Store combo box value
4 Answer(s)      5 years and 2 months ago
Posted in : Development process



Advertisement
View Answers

May 28, 2009 at 3:29 PM


Hi Friend,

Try the following code:

1) Create form.jsp

<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>

<html>
<head>
<title>Add Data</title>

<script language="javascript">
var arr = new Array();
arr["Select"] = new Array("-select-");
arr["Dkn/Tmz"] = new Array("Circulation","Marketting","Advertisment/Billing","Finance","Purchase","Administration","Internet","Business");
arr["Kungumam"] = new Array("Layout","Vannathirai","Vasantham","Aanmegam","Administration","Editorial","Finance");
arr["General"] = new Array("E-Paper","Dotcomm","ABAP","Finance","Purchase","Modem","Datalab","Scanner","QC");
arr["Others"] = new Array("Mercedes","Toyoto","Maruti","Innovo");

function change(combo1)
{
var comboValue = combo1.value;
document.forms["form"].elements["combo2"].options.length=0;
for (var i=0;i<arr[comboValue].length;i++)
{
var option = document.createElement("option");
option.setAttribute('value',i+1);
option.innerHTML = arr[comboValue][i];
document.forms["form"].elements["combo2"].appendChild(option);
}
}
function calservlet()
{
document.submit();
}
function selfSubmit()
{
document.frmIndex.action="";
document.frmIndex.submit();
}
function validate(){
if (document.form.ServiceNo.value == "")
{
alert ( "Please enter first name." );
document.form.ServiceNo.focus();
return false;
}
if (document.form.Name.value == "")
{
alert ( "Please enter last name." );
document.form.Name.focus();
return false;
}
if (document.form.CSNNo.value == "")
{
alert ( "Please enter username." );
document.form.CSNNo.focus();
return false;
}
if (document.form.Combo.value == "")
{
alert ( "Please select the department" );
document.form.Combo.focus();
return false;
}
if (document.form.IssueName.value == "")
{
alert ( "Please enter password." );
document.form.IssueName.focus();
return false;
}
if (document.form.Rem.value == "")
{
alert ( "Please enter password." );
document.form.Rem.focus();
return false;
}
if (document.form.SNo.value == "")
{
alert ( "Please enter password." );
document.form.SNo.focus();
return false;
}
if (document.form.Prcode.value == "")
{
alert ( "Please enter password." );
document.form.Prcode.focus();
return false;
}
if (document.form.Prsolved.value == "")
{
alert ( "Please enter password." );
document.form.Prsolved.focus();
return false;
}


alert("Data is successfully inserted");
return true;

}
</script>


May 28, 2009 at 3:36 PM


Hi Friend,

Try the following code:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
<html>
<head><title>Add Data</title>
<script language="javascript">
var arr = new Array();
arr["Select"] = new Array("-select-");
arr["Dkn/Tmz"] = new Array("Circulation","Marketting","Advertisment/Billing","Finance","Purchase","Administration","Internet","Business");
arr["Kungumam"] = new Array("Layout","Vannathirai","Vasantham","Aanmegam","Administration","Editorial","Finance");
arr["General"] = new Array("E-Paper","Dotcomm","ABAP","Finance","Purchase","Modem","Datalab","Scanner","QC");
arr["Others"] = new Array("Mercedes","Toyoto","Maruti","Innovo");
function change(combo1){
var comboValue = combo1.value;
document.forms["form"].elements["combo2"].options.length=0;
for (var i=0;i<arr[comboValue].length;i++){
var option = document.createElement("option");
option.setAttribute('value',i+1);
option.innerHTML = arr[comboValue][i];
document.forms["form"].elements["combo2"].appendChild(option);
}
}
function calservlet(){
document.submit();
}
function selfSubmit(){
document.frmIndex.action="";
document.frmIndex.submit();
}
function validate(){
if (document.form.ServiceNo.value == "") {
alert ( "Please enter Service No." );
document.form.ServiceNo.focus();
return false;
}
if (document.form.Name.value == "") {
alert ( "Please enter User Name." );
document.form.Name.focus();
return false;
}
if (document.form.CSNNo.value == "") {
alert ( "Please enter CSNNo." );
document.form.CSNNo.focus();
return false;
}
if (document.form.Combo.value == "") {
alert ( "Please select the department" );
document.form.Combo.focus();
return false;
}
if (document.form.IssueName.value == "") {
alert ( "Please enter issue ." );
document.form.IssueName.focus();
return false;
}
if (document.form.Rem.value == "") {
alert ( "Please enter remark." );
document.form.Rem.focus();
return false;
}
if (document.form.SNo.value == "") {
alert ( "Please enter sno." );
document.form.SNo.focus();
return false;
}
if (document.form.Prcode.value == "") {
alert ( "Please select problem code." );
document.form.Prcode.focus();
return false;
}
if (document.form.Prsolved.value == "") {
alert ( "Please select." );
document.form.Prsolved.focus();
return false;
}
return true;
}
</script>




May 28, 2009 at 3:38 PM


continue..
</head>
<Body bgcolor="#FDD017">
<form method="post" name="form" onsubmit=" return validate();" action="insert.jsp">
<br>
&nbsp;&nbsp;&nbsp; Service Number &nbsp;&nbsp;&nbsp;&nbsp; : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="ServiceNo" size="20"> <br> <br>
&nbsp;&nbsp;&nbsp; User Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="Name" size="20"> <br><br>
&nbsp;&nbsp;&nbsp; Cabinet SerialNo &nbsp;&nbsp; : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="CSNNo" size="20"><br><br>
&nbsp;&nbsp;&nbsp; Department &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <select name="Combo" onchange="change(this);">
<option value="Select">-Select-</option>
<option value="Dkn/Tmz">Dkn/Tmz</option>
<option value="Kungumam">Kungumam</option>
<option value="General">General</option>
<option value="Others">Others</option>
</option>
</select><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="combo2">
</select>
<br><br>
&nbsp;&nbsp;&nbsp; Issue &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <TEXTAREA NAME="IssueName" COLS=20 ROWS=2></TEXTAREA>
<br><br>
&nbsp;&nbsp;&nbsp; Remark &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<TEXTAREA NAME="Rem" COLS=20 ROWS=2></TEXTAREA> <br><br>
&nbsp;&nbsp;&nbsp; Sl ForNew/Alternative : &nbsp;&nbsp; <input type="text" name="SNo" size="20"> <br><br>
&nbsp;&nbsp;&nbsp; ProblemCode &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="Prcode" onChange="calservlet()";>
<option value="Select">-Select-</option>
<option value="Outlook" >Outlook</option>
<option value="Microsoft Office">Microsoft Office</option>
<option value="Virus">Virus</option>
<option value="Networking/LAN">Networking/LAN</option>
<option value="Software">Software</option>
<option value="Internet">Internet</option>
<option value="OS(Formatting Booting drive Only">OS(Formatting Booting drive Only</option>
<option value="OS Complete Format">OS Complete Format</option>
<option value="ACS2">ACS2</option>
<option value="Newswrap">Newswrap</option>
<option value="News Agencies">News Agencies</option>
<option value="Printer">Printer</option>
<option value="Xerox / Scanner">Xerox / Scanner</option>
<option value="Fax">Fax</option>
<option value="Power Supply">Power Supply</option>
<option value="New Pc/Backup PC">New Pc/Backup PC</option>
<option value="Hardware">Hardware</option>
<option value="Others">Others</option>
<option value="New/Alternative Hardware Installed">New/Alternative Hardware Installed</option>
</option>
</select>
<br><br>


May 28, 2009 at 3:39 PM


continue....
&nbsp;&nbsp;&nbsp; Problem Solved &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <select name="Prsolved">
<option value="Select">-Select-</option>
<option value="Yes" >Yes</option>
<option value="No">No</option>
</option>
</select>
<br><br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="Submit" value="submit" > &nbsp;&nbsp;
<input type="reset" value="Reset"> &nbsp;&nbsp;
<input type="button" onClick="window.print()" value="Print" />
</form>
</Body>
</html>

'insert.jsp'
<%@ pageimport="java.sql.*" %>
<%
String Service_No= request.getParameter("ServiceNo");
String UserName= request.getParameter("Name");
String CabinetSerialNo = request.getParameter("CSNNo");
String Department = request.getParameter("Combo");
String Issue = request.getParameter("IssueName");
String Remark = request.getParameter("Rem");
String SlForNew_Alternative = request.getParameter("SNo");
String ProblemCode = request.getParameter("Prcode");
String ProblemSolved = request.getParameter("Prsolved");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection("jdbc:odbc:access");
Statement statement = connection.createStatement();

String sql = ("INSERT INTO Add_Data VALUES ('" + Service_No + "','" + UserName + "','" + CabinetSerialNo + "','" + Department + "','"+ Issue +"','"+ Remark +"','"+ SlForNew_Alternative +"','"+ ProblemCode +"','"+ ProblemSolved +"')");
statement.executeUpdate(sql);
out.println("Data is inserted into the database");
statement.close();
connection.close();
%>
Thanks
Roseindia Team


Related Tutorials/Questions & Answers:
Store combo box value - Development process
Store combo box value  Hi , this is my code. Here wen i click submit button combo values are stored like 1,2,3... but i want to store value . plz... = request.getParameter("Combo"); String Issue = request.getParameter("IssueName"); String
Code to store sub combo box value - Development process
Code to store sub combo box value  Hi Deepak, In the following code i want to store subcombo box value instead of number. Already "Dkn/Tmz" ,"kungumam... etc are storing but i want to store "Circulation,marketing
Advertisements
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page...' onchange="showState(this.value)"> <option value="none">
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import...' onchange="showState(this.value)"> <option value="none">
Combo box value Error - WebSevices
Combo box value Error   if($_SERVER['REQUEST_METHOD'] == 'POST...']); } document.frmProposal.hdVisa.value = document.getElementById('cmbVisa').value; Error: The "cmbVisa" Value is Null,This error will displayed for these coding.So tell me
how to get combo box value - JSP-Servlet
how to get combo box value  i have created 1 servlet & 1 jsp page... in combo box in jsp page: (small part of my code) "> now i want... to store that id in database. how to get that value???   Hi Friend
loading value into combo box by selecting value from other combo box - JSP-Servlet
loading value into combo box by selecting value from other combo box  ... is that as i select state from state_combo_box,then the next combo box is dynamically... box with constituency corresponding to district..... all three combo box
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 pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after
how can retrive value from combo box in servlet?
how can retrive value from combo box in servlet?  i have a jsp page with combobox. And i want to get value from combox to servlet
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking the value of combo box . I am not getting it plz help me out .   hi
Code to store SubCombo box value - Development process
Code to store SubCombo box value   Hi ,In the following code i want to store SubCombo box name instead of value for Department Field. Add Data var arr = new Array(); arr["Select"] = new Array("-select-"); arr["Dkn
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  Hello friend... I can print combo box values... with html .. So i cannot use request.getParameter. If i am using null value
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.... All actions in the same page.......  Hi Friend, Please visit
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 are satisfaction in this form.. What will i do. My code is following
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...... For Example, in Student.jsp... when i click student id in combo box... in combo box from database.. by using select*from studentinformation; But when i
combo box
combo box  Hi, [_|] dropdown box [ ] [INCLUDE... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all are satisfaction in this form.. What will i do. My code is following
my table should be reseted to new value upon the selection of the combo box..
my table should be reseted to new value upon the selection of the combo box..  import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.sql.Connection
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
combo box - JSP-Servlet
combo box  how to get a combo box in jsp page which allows editing as well as list box
base the value of first combo box, how i display the second combox - JSP-Servlet
base the value of first combo box, how i display the second combox    i have a combo box for classes. my requirement is when i select the class, if class is 11 or 12 the second combo box of subject should be appear. please
assigning arraylist to combo box
assigning arraylist to combo box  Hi I am busy coding the Airline Reservation program, i have an arraylist of locations which i want to assing to the combo box. please help
date in combo box
date in combo box  strong texthello, how can i desplay the current year and next year in combo box???!!! it must be uppdate atumaticaly every year>>>
Re: base the value of first combo box, how i display the second combox - JSP-Servlet
Re: base the value of first combo box, how i display the second combox  ... value of combo box should be sent. but when i clicked to submit button, it do...); } function hide(){ if (document.getElementById) { document.getElementById('combo
Re: base the value of first combo box, how i display the second combox - JSP-Servlet
Re: base the value of first combo box, how i display the second combox    thanks for your reply. i want to know suppose the second combo box appear only when i select the class 11th or 12th. please review. your answer
Loading combo box from oracle
Loading combo box from oracle  how can i load values into a combobox from oracle database when a value is selected in another combo box
Combo Box - Struts
Combo Box  I hava acombo box cnnected to my database via html collections. When selecting an option, i want to display specific parts (sectons) on my web page....am trying to use logic:present and logic:empty but its not working
combo box connection
combo box connection  how to provide connection between three combo boxes,if my 1st combo box is course and 2nd combo box is semester and 3rd combo box is my subjects.what's the coding to provide the connection between this three
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?  ...; } function showEmp(emp_value) { if(document.getElementById("emp_id").value...="+emp_value xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url
populating the combo box - Struts
populating the combo box  Hi I am having problem populating the combo box with a table in MS SQL Server 2005 Management Studio Express. Belo is the extract from the Struct?jsp application. Sector
Helps with combo box and frame
Helps with combo box and frame  Hi i have a combobox and when i click... on the second window and click confirm i would have the information on the combo box. i... combo; JTextField txtBox; private String PersonViewing; private String
java combo box
java combo box  how to display messagedialogbox when the combobox is null, Thanks in advance
combo box code problem
combo box code problem  in this my problem related to : when i... stores the option value no like MP at option value 10 then it will stores the 10... = document.createElement("option"); option.setAttribute('value',i+1
Dojo Combo Box
Dojo Combo Box          In this section, you will learn what is combo box and how to create a combo box in dojo. For creating the Combo box  you need "
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
combo box - JSP-Servlet
combo box  I am using a JSP form in which a combobox is given and I want to populate data in it from database and on the basis of yhe selected item I want to display related data in a textbox  Hi Friend, Create
JavaScript Dynamic Combo Box
JavaScript Dynamic Combo Box Here we are going to create dynamic combo box... in respective arrays. As the user selects a country from the first combo box, the cities...: On selecting the value from the first combo, related values will get displayed
add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store... dynamically added text field but want code to retrive value of dynamically added select box also into next jsp page plz reply me as early as posssible
how to create a combo box in html
how to create a combo box in html  <tr> <td>Number<span class=mandatory>*</span></td> <td> <select name="number" id="course" style="width:158px;"> <option value="none">----Select
How to create Combo Box in SWT
How to create Combo Box in SWT       This section illustrates you how to create a combo box... an action on the second combo box. The items tea , coffee and cold drink
Combo Box operation in Java Swing
holds the integer value for the position number of he of the item in combo box... Combo Box operation in Java Swing   ... the Combo Box component, you will learn how to add items to the combo box
Retrieving Data from Database to fill Combo Box
Page with a combo box and a label. I have a database that has two fields id and an image. Now I want to fill the combo box with image and on selecting a particular image in combo box it should be displayed on the label. My combo box is only
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
JavaScript Combo Box Validation
JavaScript Combo Box Validation       This application illustrates how to validate the combo box using JavaScript validation. In this example we create a combo box of different
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... combo box which will then load the next combo box values, now i know how... to the client using ajax, and then populate the combo box, I must'nt reload
 

 

 

DMCA.com