Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,I am working on a JSP file in which I have 3 combo boxes named category, sub category & level. As soon as I select some category, I want to display the corresponding sub category & level in the respective combo-box from the datastore. I used this.form.submit() method for the same but it is not working properly. Can someone suggest me some another way of doing it?
This is my code.

XML
<tr>
<td><h2><Font color=#003366>

Category</Font></h2></td>
<%
String category="";
%>

<td> <select name="quizname" onChange="this.form.submit();">
<Option>--Select--</Option>
<%
for(Quiz q : quiz)
{
%>
<Option name="quizname"><%=q.getCategory()%></Option>
<%
}
%>
</select>
</td></tr>
<tr></tr>
<tr>
<td><h2><Font color=#003366>Subcategory</Font></h2></td>
<td><select name="subcategory">
<%
for(Quiz q : quiz)
{

    if(q.getCategory().equals(request.getAttribute("category")))
    {
        %>

<Option name="subcategory"><%=q.getSubCategory()%></Option>
<%
}
}
%>
</select>

</td></tr>
<tr></tr>
 <tr>
<td><h2><Font color=#003366>Level</Font></h2></td>
<td><select name="level">
<%
for(Quiz q : quiz)
{
    //if(category.equals(q.getCategory()))
    //{
    if(q.getCategory().equals(request.getAttribute("category")))
    {
        %>


<Option name="level"><%=q.getLevel()%></Option>



<%
}
}
%>
</table>
</select>

</td></tr>
<p>&nbsp;</p>
<INPUT TYPE=hidden NAME="email" VALUE=<%=user.getEmail() %>>
 <tr><td><input type="submit" value="Start Quiz"/>
</td></tr>



Thanks in advance.
Posted
Updated 29-Oct-11 22:50pm
v2

Hi there,

It looks like you're wanting to fetch data when the category is selected.

To do this, you can use the simple to implement the excellent jQuery UI Autocomplete[^] widget in your page. There's a great description there on it's use and implementation with several examples.

I was also able to find a JSP implementation here[^]. You should be able to use a similar approach to get that to work.

Hope this helps.

Cheers.
 
Share this answer
 
Comments
Cool Bhakti 30-Oct-11 3:55am    
Hey thanks for your help. I have provided more details. Can you please give me more suggestions?
Hey thanks for the links you provided. I referred them. But in my case what I want is when some category is selected,only those sub categories & levels corresponding to that category should be displayed in those combo-boxes and then the user will select from it.
How can the auto-complete feature be applicable in this case. The user do not have to type anything. Can you give me some more suggestions?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900