Set a radio button in a fieldset?
All...
On my JSP register page, I have a password entry field, and "Male" "Female" radio buttons.
They are set up to display side by side.
<div align="center">
<div style="width:300px;">
<fieldset class="ui-grid-a" style="height:75px;">
<div class="ui-block-a" style="padding-top:10px;">
<label for="registerPassword">Password</label>
<input type="password" name="usrPassword" id="registerPassword" autocapitalize="none" style="width:145px;" value="${requestScope.usrPassword}" />
</div>
<div class="ui-block-b" >
<fieldset data-role="controlgroup" data-mini="true" data-type="horizontal" style="padding-top:39px; padding-left:20px;">
<input type="radio" data-theme="a" name="usrGender" id="registerMale" value="male" />
<label for="registerMale">Male</label>
<input type="radio" data-theme="a" name="usrGender" id="registerFemale" value="female" />
<label for="registerFemale">Female</label>
</fieldset>
</div>
</fieldset>
</div>
If the form is submitted with errors, I want the page to refresh with the radio button that was chosen to again be selected.
In the response, I am returning the value of the selected radio button.
I use Java to process the request variable, and call Javascript to set the radio button...
<c:choose>
<c:when test="${requestScope.usrGender == 'male'}">
<script type="text/javascript">
alert("here");
$('input:radio[name="usrGender"]').filter('[value="male"]').prop('checked', true);
</script>
</c:when>
<c:when test="${requestScope.usrGender == 'female'}">
<script type="text/javascript">
$('input:radio[name="usrGender"]').filter('[value="female"]').prop('checked', true);
</script>
</c:when>
</c:choose>
Everything works fine except for setting the radio button.
I have an alert that displays "here" when the "male" button value is returned.
So I know that the code is getting to that point.
I must not be properly setting the radio button.
Am I not properly finding it in the fieldset?