Option Box Value

Option Box Value

Hi Friends,

I have one option box which is division,

division have dynamically data,if user select any division then
his option box is populated
(work schedule,Peronal Area,personal sub area,business area,trust master,payroll data)

please write the code and let me know..its urgent
View Answers

January 9, 2010 at 11:45 AM

Hi Friend,

Try the following code:

<%@page import="java.sql.*"%>
<html>
<h2>ComboBox</h2>
<script language="javascript">
var arr = new Array();
arr[0] = new Array("-select-");
arr[1] = new Array("work schedule","Peronal Area","personal sub area","business area","trust master","payroll data");
arr[2] = new Array("work schedule","Peronal Area","personal sub area","business area","trust master","payroll data");
arr[3] = new Array("work schedule","Peronal Area","personal sub area","business area","trust master","payroll data");
arr[4] = new Array("work schedule","Peronal Area","personal sub area","business area","trust master","payroll data");

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);
}
}
</script>
<form name="form" method="post">
<select name="combo1" onchange="change(this);">
<option value="0">-Select-</option>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root";, "root");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("Select * from division");
while(rs.next()){
%>
<option value="<%=rs.getString("id")%>"><%=rs.getString("divisions")%></option>
<%
}
}
catch(Exception e){}
%>
</option>

</select><br />
<select name="combo2">
</select>
</form>
</html>

For the above code we have created a table named division(id,divisions) in the database.

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
Option Box Value - Java Beginners
Option Box Value  Hi Friends, I have one option box which is division, division have dynamically data,if user select any division then his option box is populated (work schedule,Peronal Area,personal sub area,business
select option value
select option value  if i select a value of any drop down...(this.value)"> <option value="none">Select</option>...("Select * from country"); while(rs.next()){ %> <option value
Advertisements
select option value
select option value  if i select a value of any drop down...' onchange="showState(this.value)"> <option value="none">Select<...;option value="<%=rs.getString(1)%>"><%=rs.getString(2)%><
how to calculate the price on the option box
how to calculate the price on the option box  How i calculate the value when i using a option box with 2 option..first option i used for product name... to calculate this value
Option onclick am not getting the value ..
Option onclick am not getting the value ..    function get_val( tot_val ) { document.getElementById('TextBox1').value = tot_val; } <..._val( tot_val ) { document.getElementById('TextBox1').value = tot_val
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">
Jsp Option Value
Jsp Option Value   ... a select box by retrieving the value from the database in jsp. For further processing... <select name=""> <option value="">
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 display textbox value based on selected option value?
how to display textbox value based on selected option value?  Hi,I... on first value I finished above code. ID: xx Name:xx xx is baesd on second and first value. But it is that l can't do that. now, l post my code
how to get the value of a label field of option tag in javascript?
how to get the value of a label field of option tag in javascript?  example <select> <option label="2" value="A">A</option> <option label="5" value="B">B</option> <
How to assign a default value to text box in netbeans
How to assign a default value to text box in netbeans  I have a java application,and i want to assign a default variable to the textbox
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 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 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 the id in servlet page, that i have associated with value i.e "> bcoz i hav
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 show autocomplete textbox values on combo box option selection using database?
How to show autocomplete textbox values on combo box option selection using database?  When I select option(i.e First Year) then it will show list of student names in auto-complete text box
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 send me code. while validating a form, i have entered data in first field
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 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
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...;option value="A">A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option>
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...;Select Company: </td><td><select name="com"> <option value="A">A</option> <option value="B">B</option> <option
retrieve value from db in text box + calendar implementation.
retrieve value from db in text box + calendar implementation.  I have used http://www.roseindia.net/javascript/javascript-calendar.shtml code... there is already a text box..Now i want to get the value retrieved from database
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
populating one dropdown box depending on the value of other using jsp
populating one dropdown box depending on the value of other using jsp  HI i have scenario i need to populating one dropdown box depending on the value of other using the below table country name state and city name should load
jsp code for a drop down box to retrive value from database
jsp code for a drop down box to retrive value from database  my project needs to get the value from database in to the drop down box..... pls give me..."); while(rs.next()){ %> <option value="<%=rs.getString
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using... that dynamically generated text box value into database at a time without
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
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 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 retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  Hello friend... with html .. So i cannot use request.getParameter. If i am using null value... I can print combo box values
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
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
To get the value of more than one text box in an HTML page to a jsp page - JSP-Interview Questions
To get the value of more than one text box in an HTML page to a jsp page  An html file has a text box as To get the value of this text box in a JSP... file has a text box as To get the value of this text box in a JSP file
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
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below...="destination" onchange="getPrice()"> <html:option value="0">...;<input type="text" value =" " property= "amount" id='pricecheck'/> <
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below...="destination" onchange="getPrice()"> <html:option value="0">...;<input type="text" value =" " property= "amount" id='pricecheck'/>
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
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   Dear Sir, in this program when i click on submit button, the corrosponding value of combo box should be sent. but when i clicked to submit button, it do
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
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."  Hi, How to get data from MYSQL Database tables on giving a "text" in a text-box in a JSP file. Ex:dept table; if we give dept_no in a text-box in JSP
i want to select a multiple value of check box by using onclick or onchange event without using from submission
i want to select a multiple value of check box by using onclick or onchange event without using from submission   i have 4 check box name 1)profile... the result is ok but after getting value of first box now i want a result of second box
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 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
PHP List Box Post
The PHP Post List box is used in the form. It contains multiple value...='country' size="4">       <option value='UK'>UK</option>       <option value='Canada'>
Show the Value of Scroll Bar in Java Swing
the value of scrolling position in the text box. The scroll bar has multiples... Show the Value of Scroll Bar in Java Swing   ... of these components then you get the value of scrolling positions. This program shows a scrollbar
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
ModuleNotFoundError: No module named 'option'
ModuleNotFoundError: No module named 'option'  Hi, My Python... 'option' How to remove the ModuleNotFoundError: No module named 'option'... to install padas library. You can install option python with following command
select option - JDBC
select option  how to dynamically generate the select option values from database
how to use JOptionPane.YES_NO_OPTION
how to use JOptionPane.YES_NO_OPTION  As i said earliar i am making HRMS , the last phase is logout button. when logout button is clicked , an option dialog should appear which ask for yes or no . PROBLEM is i dont know how

Ads