danglingpointers
Technical User
What I would like to do is populate the radio button selections with results from a database query. Here is what I have thus far:
When the page loads, I get an error "document.forms.0.elements.button.'VALUE_OF_rs.getString()' is null or not an object.
I have checked my rendered page source and the scriptlets are returning valid values for the radio button element choices. I have tried moving the javascript code to various places around the page and have come up with the same error.
Thanks in advance.
- Tim
Code:
<% //begin JSP, call database %>
<form>
<table>
<tr>
<td><input type="radio" value="VAL1" name="button"></td>
<td><input type="radio" value="VAL2" name="button"</td>
<td><input type="radio" value="VAL3" name="button"</td>
</tr>
</table>
<table>
<tr>
<td><input type="radio" value="VAL1" name="button1"</td>
<td><input type="radio" value="VAL2" name="button1"></td>
<td><input type="radio" value="VAL3" name="button1"></td>
</tr>
<script>
document.forms[0].elements['button']['<%= rs.getString("COL_NAME") %>'].checked = true;
document.forms[0].elements['button1']['<%= rs.getString("COL_NAME") %>'].checked = true;
</script>
</form>
<% // do some more java stuff. %>
I have checked my rendered page source and the scriptlets are returning valid values for the radio button element choices. I have tried moving the javascript code to various places around the page and have come up with the same error.
Thanks in advance.
- Tim