Re: Dealing with Unchecked Checkboxes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you should a loop under the form.
my 2 cents...

Mihai

On Sat, 26 Oct 2002, Graeme McLaren wrote:

> 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:  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
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux