Jump to content

post checkbox value


Iluvatar+

Recommended Posts

You would need to put a hidden field in the form before the checkbox and use the same name as the checkbox -

<form method='post' action=''>
<input type='hidden' name='some_name' value='off'>
<input type='checkbox' name='some_name'>
<input type='submit'>
</form>

Link to comment
https://forums.phpfreaks.com/topic/259060-post-checkbox-value/#findComment-1328071
Share on other sites

So do something like

$check = isset($_POST['checkbox']) ? 1 : 0;

 

If the checkbox is checked it will be "1", if not it will be "0".

:thumb-up:

 

What he said. Using JavaScript is a really poor solution. There are sometimes hurdles when dealing with checkboxes - such as when you have a series of checkboxes to EDIT existing values. But, there are tried and true methods of handling those.

Link to comment
https://forums.phpfreaks.com/topic/259060-post-checkbox-value/#findComment-1328085
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.