Home Answers Viewqa Java-Beginners Option Box Value

 
 


Ragini Shukla
Option Box Value
1 Answer(s)      3 years and 5 months ago
Posted in : Java Beginners

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 Pages:
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
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
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)%><
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
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...;option value="">--select--</option> <option 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
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
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
select option with text facility - JSP-Servlet
select option with text facility  Hello. My doubt is regarding how to provide facility to add text in a drop down box ie(select tag in html )in a jsp... the select in html and if the user wants also to directly type the option instead
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
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
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
For every option selected from a dropdown a new textbox opens
have a dropdown with four options, each time I select an option a new text box...;select name="sel" onchange="generateTextbox();"> <option value="C/C++">C/C++</option> <option value="Java">Java</option> <option
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
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'>
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> <
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
Multiple select box
"); while(rs.next()){ %> <option value="<%=rs.getString("name")%>">...Multiple select box  Hi, I need help in code for multiple select box. The multiple select box should be populated with the db values.The selection
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'/>
combo box code problem
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... selected=3D"selected" value="0">-State-</option> <option value
selection box linked with textarea
selection box linked with textarea    function get_val(tot_val1) { document.getElementById('TextBox1').value = tot_val1; alert(tot_val1...;%-- <option onclick = "get_val('tot_val');"><%=rs.getString("vcode
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
PHP list box mysql
value from the PHP list box. Example of PHP MYSQL List Box Code <... name='roll' size="10"> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value
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
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
dynamic select box
; <input type="hidden" value="Leads" name="moduleName" /> <table>...;/label></td> <td><input type="text" name="lastname" value...="firstname" value="" /></td> </tr> <tr> <
how to create a combo box in html
="number" id="course" style="width:158px;"> <option value="none">----Select ----</option> <option >1</option> <option >2<...how to create a combo box in html  <tr> <td>Number<
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
change value - Ajax
change value  hello buddy.........please help me i have a drop down box, i have to change my text box value acording to that drop down option.........(where all i need to change to use ajax in my application
JavaScript Dynamic Combo Box
; onchange="change(this);"> <option value="0">-Select-</option> <option value="1">India</option> <option value="2">Austria</option> <option
Check Box in HTML
Check Box in HTML      ... or more option from a set of alternatives. If a user wants to select only one option... create a set of check box, this set of check box can be selected more than one
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
jsp drop down-- select Option
;nbsp;</td> <select name="sel"><option value=""><---Select... = results.getString(2); String id = results.getString(1); %><option value="<%= name %>...; <option value="none">Select</option> <% Class.forName
SubCombo box not working - Development process
SubCombo box not working  Hi, in the following code subcombo box is not working and while storing combo box numbers(1,2,3) are stored instead of values. Search Page var arr = new Array(); arr[0] = new
PHP list box
;select name='hobbie' size="4">      <option value='music'>music</option>      <option value='reading'>reading</option>      <option value
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
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
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
dialog box
dialog box to ask to quit or continue  hello. write an application... of the interview, use a dialog box to ask whether the user wants to - enter another set... question indicate how many users chose the first option,second option and so
dialog box
dialog box to show latest question  hello. write an application... of the interview, use a dialog box to ask whether the user wants to - enter another set... question indicate how many users chose the first option,second option and so
dialog box
possible numeric choice answers. at the end of the interview, use a dialog box... chose the first option,second option and so on thank u
dialog box
possible numeric choice answers. at the end of the interview, use a dialog box... chose the first option,second option and so on thank u
dialog box
possible numeric choice answers. at the end of the interview, use a dialog box... chose the first option,second option and so on thank u
dialog box
possible numeric choice answers. at the end of the interview, use a dialog box... chose the first option,second option and so on thank u
dialog box
possible numeric choice answers. at the end of the interview, use a dialog box... chose the first option,second option and so on thank u
dialog box
possible numeric choice answers. at the end of the interview, use a dialog box... chose the first option,second option and so on thank u

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.