Re: Returning values from checkboxes
| From: | Daniel Convissor | Date: | Tue, 21 Nov 2000 20:02:17 +0000 |
| Subject: | Re: Returning values from checkboxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26509@lists.php.net to get a copy of this message | ||
Daniel Alsén wrote:
>
> Hi,
>
> how do i return values from checkboxes in forms?
>
> ie i have a form with a checkbox. How do i, later in the same php-document,
> find out if the box was checked or not?
<form action="script.php" method="post">
<input type="checkbox" name="Code[]" value="34001" />Atlantic,
NJ
<input type="checkbox" name="Code[]" value="34003" />Bergen, NJ
<input type="checkbox" name="Code[]" value="34005" />Burlington,
NJ
<input type="checkbox" name="Code[]" value="34007" />Camden, NJ
<input type="submit" />
</form>
> Can i use the name of the check box in an if-statement (if (checkbox="?) )?
> And what would i replace ? with (what value does the box return)?
Oh, you are asking about a single check box. Like, a check box asking, "Do
you want us to send you junkmail?"
<form action="script.php" method="post">
<input type="checkbox" name="Junk" value="yes" />Junkmail?
<input type="submit" />
</form>
if ($Junk == "yes") {
mail("you@spam4you.net","the junk you requested");
# :)
}
Enjoy,
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409