marain
04-21-2013, 07:01 PM
I'm having difficulty forcing focus upon a radio field element. Here are the techniques I've tried, all unsuccessfully:
Original Effort:
html
<tr>
<td class="prompt">Age of person charged:</td>
<td class="input">
under 18 <input type="radio" name="defage" value="u18" />
18-21 <input type="radio" name="defage" value="18-21" />
22-30 <input type="radio" name="defage" value="22-30" />
over 30 <input type="radio" name="defage" value="o30" /></td>
</tr>
javascript
var chosen = checkOne( "defage" )
if ( chosen < 0 ) {
alert( "Please make your selection at Age of person charged." );
document.form.defage.focus();
return false;
}
Modification One: Add name to prompt element
html
<tr>
<td class="prompt" name="pdefage">Age of person charged:</td>
<td class="input">
under 18 <input type="radio" name="defage" value="u18" />
18-21 <input type="radio" name="defage" value="18-21" />
22-30 <input type="radio" name="defage" value="22-30" />
over 30 <input type="radio" name="defage" value="o30" /></td>
</tr>
javascript
var chosen = checkOne( "defage" )
if ( chosen < 0 ) {
alert( "Please make your selection at Age of person charged." );
document.form.pdefage.focus();
return false;
}
Modification Two: Insert hidden field
html
<tr>
<td class="prompt">Age of person charged:</td>
<td <input type="hidden" name="hdefage">
<td class="input">
under 18 <input type="radio" name="defage" value="u18" />
18-21 <input type="radio" name="defage" value="18-21" />
22-30 <input type="radio" name="defage" value="22-30" />
over 30 <input type="radio" name="defage" value="o30" /></td>
</tr>
javascript
var chosen = checkOne( "defage" )
if ( chosen < 0 ) {
alert( "Please make your selection at Age of person charged." );
document.form.hdefage.focus();
return false;
}
Wherefore the error of my ways?
A.
Original Effort:
html
<tr>
<td class="prompt">Age of person charged:</td>
<td class="input">
under 18 <input type="radio" name="defage" value="u18" />
18-21 <input type="radio" name="defage" value="18-21" />
22-30 <input type="radio" name="defage" value="22-30" />
over 30 <input type="radio" name="defage" value="o30" /></td>
</tr>
javascript
var chosen = checkOne( "defage" )
if ( chosen < 0 ) {
alert( "Please make your selection at Age of person charged." );
document.form.defage.focus();
return false;
}
Modification One: Add name to prompt element
html
<tr>
<td class="prompt" name="pdefage">Age of person charged:</td>
<td class="input">
under 18 <input type="radio" name="defage" value="u18" />
18-21 <input type="radio" name="defage" value="18-21" />
22-30 <input type="radio" name="defage" value="22-30" />
over 30 <input type="radio" name="defage" value="o30" /></td>
</tr>
javascript
var chosen = checkOne( "defage" )
if ( chosen < 0 ) {
alert( "Please make your selection at Age of person charged." );
document.form.pdefage.focus();
return false;
}
Modification Two: Insert hidden field
html
<tr>
<td class="prompt">Age of person charged:</td>
<td <input type="hidden" name="hdefage">
<td class="input">
under 18 <input type="radio" name="defage" value="u18" />
18-21 <input type="radio" name="defage" value="18-21" />
22-30 <input type="radio" name="defage" value="22-30" />
over 30 <input type="radio" name="defage" value="o30" /></td>
</tr>
javascript
var chosen = checkOne( "defage" )
if ( chosen < 0 ) {
alert( "Please make your selection at Age of person charged." );
document.form.hdefage.focus();
return false;
}
Wherefore the error of my ways?
A.