Promblems Ajax Checkbox Value
- Forums
- Javascipt
- Promblems Ajax Checkbox Value
Having Some Problem With Ajax Checkbox Value In The Web Form, I Had A Field Type Checkbox, So When I Would Submit The Form, The Post Information Would Always Be The Value Of The Forms [2212], Last Updated: Mon Jun 24, 2024
Webune Support
Fri Feb 12, 2010
0 Comments
394 Visits
today i was doing some javascript and was using AJAX for a form.
in the web form, i had a field type checkbox, so when i would submit the form, the POST information would always be the value of the forms.
for example. this is how the checkbox input field looks like:
<input type="checkbox" id="agree" name="agree" value="1">
so normally, if you have check the checkbox, then the default value would apply, in this case 1,
but even after submitting the form without checking the checkbox, the value would still be 1?
what am i doing wrong? OK, i finally found out what i was doing wrong. in my javascript code i had declared the value of my ajax field to the value instead of checked so i changed it and it worked:
BEFORE:
var terms = document.getElementById('terms').value;
AFTER:
var terms = document.getElementById('terms').checked;
do you see the difference?