Kunal Batra
Kunal Batra

Reputation: 991

Drop-down in Spring MVC

Drop-down is not showing in browser, it's only displaying the options name without the drop-down list.

I also want to call a JavaScript function on select of drop-down and on the next page. How can I display selected option that user select from drop down? Code of my page is:

<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<form:select path="phone">
    <form:option value="samsung">SAMSUNG</form:option>
    <form:option value="nokia">NOKIA</form:option>
    <form:option selected="selected" value="htc">HTC</form:option>
    <form:option value="iphone">IPHONE</form:option>
</form:select>

And when I run my project it's showing all the values without display drop down list:

Result of my code is

Upvotes: 1

Views: 514

Answers (1)

MDaniyal
MDaniyal

Reputation: 1097

Try this:

<form:select path="state">
<form:options items="${lang_choose_option}" />
</form:select>

and your output will be:

<select name="state">
    <option value="1">Alabama</option>
    <option value="2">Alaska</option>
    <option value="3">Arizona</option>
    <option value="4">Arkansas</option>
    <option value="5">California</option>
</select>

Upvotes: 4

Related Questions