I have the following scenario and I'm trying to use spring MVC:
I have form to enter a user address with number, street, city, etc. Also, on the form I have a combobox/<select> holding a list of states as follows:
Code:
<spring:bind path="address.state">
<select size="1" name="<c:out value="${status.expression}"/>" onchange="submit()">
<c:forEach var="state" items="${states}">
<option value="<spring:transform value="${state.state}"/>"
<c:if test="${address.state.state==state.state}">SELECTED</c:if>>
<c:out value="${state.stateAbbr}"/>
</option>
</c:forEach>
</select>
<font color="red"><c:out value="${status.errorMessage}"/></font>
</spring:bind>
and a combobox/<select> holding a list of counties for the selected state as follows:
Code:
<spring:bind path="address.county">
<select size="1" name="<c:out value="${status.expression}"/>">
<c:forEach var="county" items="${counties}">
<option value="<spring:transform value="${county.county}"/>"
<c:if test="${address.county.county==county.county}">SELECTED</c:if>>
<c:out value="${county.countyName}"/>
</option>
</c:forEach>
</select>
<font color="red"><c:out value="${status.errorMessage}"/></font>
</spring:bind>
What I would like to happen is that when a user changes the selection of the state that the county combobox/<select> list would be repopulated with the counties of the newly selected state.
Does anyone have a solution to a situation like this? Can this be done with Spring MVC alone? Is javascript necessary?