I'm having difficulty forcing focus upon a radio field element. Here are the techniques I've tried, all unsuccessfully:
Original Effort:
html
Code:<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
Code: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
Code:<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
Code: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
Code:<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
Code: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.



Reply With Quote

Bookmarks