jquery - How to show selected value in dropdown list -


After submitting the JSP page request, the servlet goes to the form text fields and dropdown lists to fill an item on the JSP page I need to send an object like servlet needs.

The user will enter the ID value in the form and we will have to get it from the data

Initially when the JSP page is loaded Then the dropdown list value should be derived from the database

Problem:

After submission, show how the value derived from the database in the dropdown list box.

Because it is conflicting with the previous scenario (get the value dynamically from the database on load) !!

  / * & lt; Sql: setDataSource driver = "sun.jdbc.odbc.JdbcOdbcDriver" url = "jdbc: odbc: lab" var = "local source" /> & Lt; sql: query data source = "$ {local resource}" select sql = "cate_id, category" var = "result" /> to cate_desc & lt; Select name = "cate_id"> & Lt; C: forEach item = "$ {result.rows}" var = "r" & gt; & Lt; C: Select & gt; & Lt; C: when test = "$ {r.cate_id eq a}" & gt; // I received a price from the request .getattribute & lt; Option value = "$ {r.cate_id}" selected = "selected" & gt; $ {R.cate_desc} & lt; / Options & gt; & Lt; / C: When & gt; & Lt; C: otherwise & gt; & Lt; Option value = "$ {r.cate_id}" & gt; $ {R.cate_desc} & lt; / Options & gt; & Lt; / c: Otherwise & gt; & Lt; / c: Select & gt; & Lt; / C: foreach & gt; & Lt; / Select & gt;   

* /

The problem

This value is showing values ​​in the checkbox as it should be, but after submitting the form < / P>

The page that selects the value in the checkbox is not showing.

  and <.sun.com / jsp / jstl to submit the form using jsp: jsp:  

/ core "prefix =" c "%>

at the top of jsp, present form such as to show the selected value in the dropdown list :

type = "id" /> name action:
  & quot; action action = "some action" method = "post" & gt; Id: & lt; name: & lt ; Input type = "text" name = "name" /> option: & lt; select name = "selected options" & gt; & lt; c: forEach item = "$ {userFormDTO.options}" var = "Opt"> gt; & lt; c: select & gt; & lt; c: When the test = "$ {opt eq userFormDTO.selectedOption}" & gt; & lt; option value = "$ {opt}" selected = "selected"> $ {opt}  gt; & lt ; / C: When & gt; & lt; c: Otherwise & gt; Option value = "$ {opt}" & gt; $ {opt} & lt; / option & gt; & lt; / c: Otherwise, click >> & lt; / c: Select & gt; & lt; / c: foreach & gt; & lt; / select & gt; & lt; input type = "submit" /> & lt; / Form & gt;   


Note: jstl.jar to & lt; C: Use of tags should be available in CLASSPATH.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -