Radio Buttons and Select Lists in JSP
843836Nov 2 2004 — edited Nov 3 2004Hi,
I need some help with Radio buttons and select lists. I have a registration page and I've stored the values in the database, which were taken from radio buttons and the select list.
I want to display the selected item in the radio button list and the select list, I am able to do that, but I want it to point to the entry in the existing list and not only display the value from the database. My code is iterating over the database value but not the list values, and I don't know how to do it
Here is my code to explain it more:
<c:when test="${row.choice == 'cars'}">
<input type="radio" name="cars" value="${fn:escapeXml(row.choice)}" checked><c:out value="${fn:escapeXml(row.choice)}"/>
<!-- Until this point it gives me the values from the database -->
<input type="radio" name="cars" value="mercedesl">Mercedes
<input type="radio" name="cars" value="ford">Ford
<input type="radio" name="cars" value="bmw">BMW
<input type="radio" name="cars" value="vw">Volkswagen
What I want it to do is get the value from the database, iterate through the list of existing values in the radio button selection and select/check the appropriate button instead of directly getting the information from the database.
The same goes for the following selection list:
<select name="Country">
<option value="${fn:escapeXml(row.country)}"><c:out value="${row.country}"/>
<option value="Albania">Albania
<option value="Austria">Austria
<option value="Belarus">Belarus
<option value="Belgium">Belgium
<option value="BozniaHerzegovina">Boznia and Herzegovina
<option value="Bulgaria">Bulgaria
<option value="Croatia">Croatia
<option value="CzechRepublic">Czech Republic
I don't really know how to continue to get it to point to the values I want.
Can someone help me out? I would really appreciate it...
Thank you