gerkintrigg Posted November 25, 2009 Share Posted November 25, 2009 I set the checkbox to have a checked value of "y" and I want to set the form to post the value as a variable to a javascript script. I'm trying this: onclick(checkbox(my_box.value)) but it just says "undefined". Is there an easy way to make it say "n"? Even when it is checked, it still says undefined so perhaps I'm being dumb... though it is very late here. Link to comment https://forums.phpfreaks.com/topic/182854-getting-the-value-of-a-checkbox/ Share on other sites More sharing options...
Viola Posted November 25, 2009 Share Posted November 25, 2009 If a checkbox is checked, the value is posted, otherwise it is not. You would need to say something like if checkbox value is empty then cbxValue = 'n'; else cbxValue = checkbox value; then use cbxValue. Link to comment https://forums.phpfreaks.com/topic/182854-getting-the-value-of-a-checkbox/#findComment-965219 Share on other sites More sharing options...
gerkintrigg Posted November 25, 2009 Author Share Posted November 25, 2009 yeah, that's what i figured... damn. Link to comment https://forums.phpfreaks.com/topic/182854-getting-the-value-of-a-checkbox/#findComment-965594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.