Home > Java > javaTutorial > body text

drop down list in jsp page

(*-*)浩
Release: 2019-05-24 15:03:09
Original
3713 people have browsed it

In the process of WEB development, we often encounter functional requirements for information modification. At this time, we provide the user with a JSP page that displays the current information and allows the user to reset the new value.

drop down list in jsp page

In this page, a drop-down list is generally indispensable. As for its processing method, I have thought of one before, and the idea is as follows: set a hidden field on the page to save the value passed from the background; then output the drop-down list on the page, and its value is the default at this time, that is, the first One item; get the value in the hidden field in the js code snippet and determine whether it is equal to the id value of the drop-down item in the loop. If equal, set the selected status of the item. Because this method is too cumbersome.

The following are two commonly used processing methods.

Method one:

<select id="user_id" name="user_id">
   	<c:forEach items="${users}" var="u">
   	<option value="${u.id }" <c:if test="${user.user_id==u.id}"><c:out value="selected"/></c:if>>
   	${u.name}
   	</option>
   	</c:forEach>
</select>
Copy after login

Method two:

<select id="projectPorperty" name="projectPorperty">
   	<option value="1">实施</option>
   	<option value="0">研发</option>
</select>
<script>
   	form.projectPorperty.value = '${user.projectPorperty}';
</script>
Copy after login

The above two methods have their own advantages and disadvantages. Choose as appropriate according to the situation!

The above is the detailed content of drop down list in jsp page. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
jsp
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template