vozzek Posted October 9, 2007 Share Posted October 9, 2007 Hi everyone, Java newbie here, so please bear with me. I really tried this 10 different ways by now, and only came here when I was absolutely stumped. I've got a form (form1) with 2 fields. One is a Y/N radio button called 'customizable'. The other is a text field called 'character_limit'. I want 'customizable' defaulted to 'N' (already have that) with the 'character_limit' field disabled. But when 'customizable' is clicked to 'Y', I want 'character_limit' to be enabled. I've tried this directly with the following code: <tr valign="baseline"> <td align="right" valign="top" nowrap="nowrap">Customizable:</td> <td valign="baseline"><table> <tr> <td><input onclick="document.character_limit.disabled = false" type="radio" name="customizable" value="Y" /> Yes</td> </tr> <tr> <td><input onclick="document.character_limit.disabled = true" type="radio" name="customizable" value="N" checked="N" /> No</td> </tr> </table></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Character Limit:</td> <td><input name="character_limit" type="text" value="" size="32" maxlength="3" disabled="disabled"/> </td> </tr> I also tried creating a function that looks like this: <script type="text/javascript"> <!-- function disable_enable(){ if (document.all || document.getElementById){ if (document.form1.customizable.value=='Y') document.form1.character_limit.disabled=false else document.form1.character_limit.disabled=true } } </script> The function looks good, but I'm not sure exactly where (or how) to place the code that calls that function. Sorry if this is a pretty elementary question, but I'm still learning. Thanks in advance for the help. Quote Link to comment Share on other sites More sharing options...
fenway Posted October 9, 2007 Share Posted October 9, 2007 Should be fine in the onclick handler... you should go through doc.forms.elements, though. Quote Link to comment Share on other sites More sharing options...
vozzek Posted October 9, 2007 Author Share Posted October 9, 2007 Ahhhhh, crap! Sometimes the most obvious things are the hardest to solve. You nailed it. I changed: input onclick="document.character_limit.disabled = true" to input onclick="document.form1.character_limit.disabled = true" and I am now a happy camper. Thanks fenway! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.