Re: Dealing with Unchecked Checkboxes
| From: | Graeme McLaren | Date: | Sat, 26 Oct 2002 22:14:38 +0000 |
| Subject: | Re: Dealing with Unchecked Checkboxes | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22718@lists.php.net to get a copy of this message | ||
Mihail, do u mean something like this?
<?
if (!isset($pick)) {
echo "Fill out and submit the form below."; }
else {
$j = count($pick);
for($i=0; $i<$j; $i++) {
echo "Pick <b>$pick[$i]</b> is Checked<br />"; }
}
?>
<form action="<? echo $PHP_SELF; ?>">
<ol>
<li>Painting<input name="pick[]" type=checkbox value="Painting"
/></li>
<li>Plumbing<input name="pick[]" type=checkbox value="Plumbing"
/></li>
<li>Electric<input name="pick[]" type=checkbox value="Electric"
/></li>
</ol>
<input type="submit" value="Submit!" />
<input type="reset" value="Reset" />
</form>
Cheers,
Graeme :)
----- Original Message -----
From: "Mihail Bota" <mbota@almaak.usc.edu>
To: "Micah Stevens" <micah@raincross-tech.com>
Cc: <php-db@lists.php.net>
Sent: Saturday, October 26, 2002 10:01 PM
Subject: Re: [PHP-DB] Dealing with Unchecked Checkboxes
> Try to assign a value for each of these variables, or elements of array.
> If it is checked let's say is =1,otherwise=0. Then grab the whole set of
> variables with GET_VARS or something like this. Create the new array in
> the page where you insert data, and then use if's to insert data in your
> tables.
> I am pretty sure is not the cleanest way, but I hope it makes sense.
>
> Mihai
>
> On Sat, 26 Oct 2002, Micah Stevens wrote:
>
> > Unchecked checkboxed do not return a value. They don't return a NULL or
> > empty string or anything. So what you have to do is check to see if the
> > variable is set. If it is set, then it's checked, if it's not set, then
> > it's unchecked.
> >
> > Kinda sucks if your variable names are dynamic, I just erase the whole
> > record and re-insert in that case.
> >
> > -Micah
> >
> >
> > At 09:02 PM 10/26/2002 +0100, Graeme McLaren wrote:
> > >Hey all, I'm trying to get my head around checkboxes. I can insert
> > >"checked" checkboxes into a DB no problem but I get an error when the
> > >checkboxes are unchecked. I've used the following to try and handle
> > >unchecked checkboxes but I still get the error "query was empty" can
> > >anyone point me in the right direction?
> > >
> > >
> > >$number=count($GiftWrapping);
> > > for($a=0;$a<$number;$a++)
> > >{
> > > echo $GiftWrapping[$a];
> > > if ( empty( $GiftWrapping ) )
> > > {
> > > $GW = 'N';
> > > }
> > >
> > >INSERT INTO DB CODE HERE
> > >
> > >GiftWrapping = '$GW'";
> > >
> > >}
> > >
> > >
> > >Cheers in advance,
> > >
> > >Graeme :)
> > >
> > >
> > >Public Sub House()
> > >
> > >On Error Resume drink
> > >
> > > If Pint.empty = True Then
> > > Pint.refill
> > > Else
> > > Pint.drink
> > > End if
> > >
> > >stomach.add Pint
> > >
> > >MsgBox " I've had .... " & stomach.count & " Pints"
> > >MsgBox "VERY DRUNK"
> > >
> > >End Sub
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>