base the value of first combo box, how i display the second combox

Ads
 

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 let me how i implement this in JSP.


<%! int i=1; %>
<tr><td>Class</td><td><select name="class_name">
<%
for( i=1;i<=12;i++){
%>
<option value="<%=i%>"><%=i%></option>
<%
}
if(i==11)
{
%>
</select></td>
Subject</td><td><select name="subject" >
<option value="1">Art</option>
<option value="2">Commerce</option>
<option value="3">Science</option>
</select></td></tr>
<%
}
%>

please suggest.
View Answers

April 1, 2010 at 2:34 PM

Hi Friend,

Try the following code:

<html>
<h2>ComboBox</h2>
<script language="javascript">
var arr = new Array();
arr[11] = new Array("Art","Commerce","Science");
arr[12] = new Array("Art","Commerce","Science");

function change(class_name)
{
var comboValue = class_name.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="class_name" onchange="change(this);">
<%
for( int i=1;i<=12;i++){
%>
<option value="<%=i%>"><%=i%></option>
<%
}
%>
</select><br>
<select name="combo2">
</select>
</form>
</html>

Thanks

Ads









Related Tutorials/Questions & Answers:
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
how to select second combobox value .
how to select second combobox value .  I requirement is , i have two combo box, i am selected first combo box value then automatically second combo box value show ,But this both combo box value i retrieves in database. please
Advertisements
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...(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after submit i want to display other field. how to get it?? plz help me
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 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">
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.  I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid
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
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
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
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
How to get the values from the Combo Box - JSP-Servlet
, Actually i am getting the values in the combo box from table.I want what ever the value i select in combo box its corresponding records will display in their respective text box. e.g suppose i select ram values from the combo box and its
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
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
combo box
combo box  Hi, [_|] dropdown box...] My question is i want to develop a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get
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>>>
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
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... Started with "S" will Automatically Display as Combo Box Items. So will you
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
How to create textbox on combo value selection using javacsript in jsp?
How to create textbox on combo value selection using javacsript in jsp?  dynamically create textbox on combo value selection. when select multiple values then create multiple textboxes
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
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
Helps with combo box and frame
on the second window and click confirm i would have the information on the combo box. i don't really know how to doing it.   Sorry i forget to put my code i...Helps with combo box and frame  Hi i have a combobox and when i click
how to display textbox value based on selected option value?
how to display textbox value based on selected option value?  Hi,I have some problem. I use jsp and ajax. first select: 1 second select:2 based on first value I finished above code. ID: xx Name:xx xx is baesd on second
how to display webservice response in a text box
how to display webservice response in a text box  Hallo, i have created a webservice and when i sended request to my webservice its sending proper response . the point is how to dispaly the response values in a text box usinj
i want to select a multiple value of check box by using onclick or onchange event without using from submission
)1000-1500 3)1500-2000 4)2000-2500 when i am selecting first value of checkbox the result is ok but after getting value of first box now i want a result of second box...i want to select a multiple value of check box by using onclick or onchange
combox
combox   i have one table in database item master..if i select one item throug combo box than other combobox show item price only select item name... how i can implement through jsp in a single jsp page.   We have used

Ads