R
Robert S
I have a form with a checkbox:
<form method="post" action="test.php">
<input type="checkbox" name="foo" checked>
<input type="submit">
</form>
If the checkbox is checked, $_POST['foo'] gets assigned the value
"on" (using php as the second file)
But if the checkbox is unchecked, $_POST['foo'] is not assigned.
Is there a simple way that I can set an arbitrary value to this
(eg."off"), if the checkbox is not checked? An onClick method for the
submit button would be a good start.
I'm sure this must be a common problem, but I can't find a simple,
relatively generic solution on the web.
<form method="post" action="test.php">
<input type="checkbox" name="foo" checked>
<input type="submit">
</form>
If the checkbox is checked, $_POST['foo'] gets assigned the value
"on" (using php as the second file)
But if the checkbox is unchecked, $_POST['foo'] is not assigned.
Is there a simple way that I can set an arbitrary value to this
(eg."off"), if the checkbox is not checked? An onClick method for the
submit button would be a good start.
I'm sure this must be a common problem, but I can't find a simple,
relatively generic solution on the web.