When you submit a form with empty fields, empty values are posted, except for checkboxes which are not posted at all, just as if they were no such field in the form. However if you need to know whether a checkbox is checked or not, you can simply add a hidden field with the same name.
<input type="hidden" name="mycheck" value="" /> <input type="checkbox" name="mycheck" value="on" /> |
If the checkbox is unchecked the value of the hidden field would be part of the submitted request. If the checkbox is checked the value of the checkbox would be “checkbox=on”. This is a much simpler solution that doesn’t require writing any additional code or sending an array of checkboxes.
Share this
The Author
admin - Hello, my name is Simon, I’am 25 and I’m a software and web developer. My interests span all aspects of programming and development, including ASP, JavaScript, AJAX, PHP, .NET, Java, C#, C++, Objectv-C, Flash, Cocoa, SQL, XML and everything in between. www.simra.ch