无需单击提交按钮即可获取表单值

问题描述:

朋友,您好,我正在处理一个JSP文件,其中有3个组合框,分别名为category,sub category&.等级.选择某个类别后,我想立即显示相应的子类别&数据存储区中相应组合框中的级别.我也使用了this.form.submit()方法,但是它无法正常工作.有人可以建议我其他方法吗?
这是我的代码.

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.

<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.

您好,

选择类别后,您似乎想获取数据.

为此,您可以使用简单的实现出色的jQuery UI自动完成 [此处 [ ^ ].您应该能够使用类似的方法来使其工作.

希望这会有所帮助.

干杯.
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.


谢谢您提供的链接.我介绍了他们.但是对于我来说,我想要的是选择某个类别时,只有那些与该类别相对应的子类别和级别应显示在那些组合框中,然后用户才能从中进行选择.
在这种情况下如何应用自动完成功能.用户不必键入任何内容.您能再给我一些建议吗?
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?