iPixel Posted December 14, 2009 Share Posted December 14, 2009 Am i doing something wrong? 2 Radio Buttons... <input type="radio" name="form_status" id="form_status" value="Active" onchange="ETDF(this)" /> Active <input type="radio" name="form_status" id="form_status" value="InActive" onchange="ETDF(this)" /> InActive So if "Active" is selected... the field form_termdate has to be disabled, otherwise if InActive is selected the form_termdate field (textbox) has to be enabled. my JS. <script type="text/javascript"> if(document.getElementById("form_status") == "Active") { document.getElementByID("form_termdate").disabled = true; } function ETDF(action) // Enable Terminated Date Field { if(action == "Active") { document.getElementByID("form_termdate").disabled = true; } else if(action == "InActive") { document.getElementByID("form_termdate").disabled = false; } } </script> Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/185136-disabling-a-field-based-on-radio-button-selection/ Share on other sites More sharing options...
akitchin Posted December 14, 2009 Share Posted December 14, 2009 you're passing the function an object (the radio button element), but you can't compare the object directly to the value you're expecting. you have to use the value property: if(action.value == "Active") give that a whirl. Link to comment https://forums.phpfreaks.com/topic/185136-disabling-a-field-based-on-radio-button-selection/#findComment-977304 Share on other sites More sharing options...
iPixel Posted December 14, 2009 Author Share Posted December 14, 2009 That's a no go. Link to comment https://forums.phpfreaks.com/topic/185136-disabling-a-field-based-on-radio-button-selection/#findComment-977321 Share on other sites More sharing options...
akitchin Posted December 15, 2009 Share Posted December 15, 2009 okay.... are you getting any error messages? have you checked the javascript error console in firefox? it could be that it's tripping on the first if() as well, where you check the object itself against a value, rather than the object's value property. Link to comment https://forums.phpfreaks.com/topic/185136-disabling-a-field-based-on-radio-button-selection/#findComment-977536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.