Get the selected value from a Select box and check that value against an array in the same form
Posted
by Rob Allen
on Stack Overflow
See other posts from Stack Overflow
or by Rob Allen
Published on 2010-05-04T19:10:11Z
Indexed on
2010/05/04
19:48 UTC
Read the original article
Hit count: 276
I'm new to JSTL/EL and JSP and can't seem to find a reference which covers the following scenario:
I have an array of values in JavaScipt:
var Countries = ('US', 'CA');
I then need to check to see if the currently selected value of a standard HTML select
box is in that array.
This is what I have so far:
<select id="shippingCountry">
<option value="AT">Austria</option>
<option value="CA">Canada</option>
<option value="DE">Germany</option>
//...
<option value="US">United States</option>
</select>
<c:choose>
<c:when test=" "> // I don't know what to put in the 'test' case
<span class="required">*</span>
</c:when>
</c:choose>
© Stack Overflow or respective owner