Populating cascading dropdown lists in JSP/Servlet

后端 未结 4 1439
[愿得一人]
[愿得一人] 2020-11-22 03:32

Suppose I am having three dropdownlist controls named dd1, dd2 and dd3. The value of each dropdownlist comes from database. dd3<

4条回答
  •  时光说笑
    2020-11-22 04:27

    Judging by your question, you're really not using a web framework but using servlets to render html.

    I'll be nice and say that you're about a decade behind the times :), people use JSPs (and a web framework like struts) for this sort of thing. However, having said that, here goes:

    1. Create a hidden field in your form and set the value to '1', '2' or '3' depending on which drop down is to be populated;
    2. In your servlet, capture this value (request.getParamter()) and use it a 'case'/if/else statement to return the appropriate dropdown values.

    I'll say it again, just use a web-framework, or atleast plain old jsp to do this.

提交回复
热议问题