html - saving value selected in a list when submit button is clicked -
in jsp have dropdownlist , submit button when clicking submit button lose value selected in list. using jstl because need construct other table corresponding value selected in list.for must call submit button problem; reset value selected
i want know if there way save value selected in list click submit button. work jsp , eclipse environment.
thank help.
you need preset inputs request parameter values. can access parameter values in el ${param.name}
. in case of dropdowns rendered html <select>
element, need set selected
attribute of html <option>
element in question. can make use of ternary operator in el print selected
attribute whenever option value matches request parameter value.
basic example:
<select name="foo"> <c:foreach items="${options}" var="option"> <option ${param.foo == option ? 'selected' : ''}>${option}</option> </c:foreach> </select>
Comments
Post a Comment