This is my jsp code that i've used for populate my form with the database value dinamically. This code works fine. "maritalStatusList" is the model that returns by spring jdbc template.
<select name="MaritalStatus">
<c:forEach var="maritalStatus" items="${maritalStatusList}">
<option value="${maritalStatus.getMaritalStatusId() }">${maritalStatus.getMaritalStatusNameEng()
}</option>
</c:forEach>
</select>
My dtabase is look like this:
maritial_status_id | maritial_status
1 | married
2 | unmarried
Now, there is a search button in my form which returns the id of marital status searched by mobile number. I need to auto populate this dropdown list with the searched value. How can i do that ?
(Auto populated means selected)