Re: [PHP-DB] Dealing with Unchecked Checkboxes
Hi all, thanks for all your replies, I got the problem with checkboxes fixed :) Cheers, Graeme :) - Original Message - From: <[EMAIL PROTECTED]> To: "Graeme McLaren" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, October 28, 2002 3:53 PM Subject: Re: [PHP-DB] Dealing with Unchecked Checkboxes > > how about a default value...so if you use a CHECKBOX_FIELD1 ENUM('Y', 'N') > DEFAULT N type of definition, then if box is not checked, then it will > deault to N otherwise a Y will override the default. > > just a thoughtdont' know if it will work for you or not... > Jeff > > > > Brent Baisley > > r.com> cc: <[EMAIL PROTECTED]> > Subject: Re: [PHP-DB] Dealing with Unchecked Checkboxes > 10/28/2002 > 10:49 AM > > > > > > > If you want to have an answer for each item, you should use yes/no radio > buttons. With checkboxes you only get "yes" answer, as you are aware. > The assumption is that you could care less about "no" answers since you > are only interested in the "yes" set. > > Checkboxes "reveal" yes answers, radio buttons can "reveal" yes or no > (or perhaps no answer if there is no default). > > If you want to stick with checkboxes, then I would have a hidden field > for each checkbox you have. The hidden field could then be set with a > "yes" or "no" value via javascript and an onChange event capture. > > > On Saturday, October 26, 2002, at 05:02 PM, 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. > -- > Brent Baisley > Systems Architect > Landover Associates, Inc. > Search & Advisory Services for Advanced Technology Environments > p: 212.759.6400/800.759.0577 > > > -- > 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
Re: [PHP-DB] Dealing with Unchecked Checkboxes
how about a default value...so if you use a CHECKBOX_FIELD1 ENUM('Y', 'N') DEFAULT N type of definition, then if box is not checked, then it will deault to N otherwise a Y will override the default. just a thoughtdont' know if it will work for you or not... Jeff Brent Baisley r.com> cc: <[EMAIL PROTECTED]> Subject: Re: [PHP-DB] Dealing with Unchecked Checkboxes 10/28/2002 10:49 AM If you want to have an answer for each item, you should use yes/no radio buttons. With checkboxes you only get "yes" answer, as you are aware. The assumption is that you could care less about "no" answers since you are only interested in the "yes" set. Checkboxes "reveal" yes answers, radio buttons can "reveal" yes or no (or perhaps no answer if there is no default). If you want to stick with checkboxes, then I would have a hidden field for each checkbox you have. The hidden field could then be set with a "yes" or "no" value via javascript and an onChange event capture. On Saturday, October 26, 2002, at 05:02 PM, 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. -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- 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
Re: [PHP-DB] Dealing with Unchecked Checkboxes
If you want to have an answer for each item, you should use yes/no radio buttons. With checkboxes you only get "yes" answer, as you are aware. The assumption is that you could care less about "no" answers since you are only interested in the "yes" set. Checkboxes "reveal" yes answers, radio buttons can "reveal" yes or no (or perhaps no answer if there is no default). If you want to stick with checkboxes, then I would have a hidden field for each checkbox you have. The hidden field could then be set with a "yes" or "no" value via javascript and an onChange event capture. On Saturday, October 26, 2002, at 05:02 PM, 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. -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Dealing with Unchecked Checkboxes
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 $pick[$i] is Checked"; } > } > ?> > > > > Painting > Plumbing > Electric > > > > > > > > Cheers, > > Graeme :) > > - Original Message - > From: "Mihail Bota" <[EMAIL PROTECTED]> > To: "Micah Stevens" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > 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 > > > > > -- > 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
Re: [PHP-DB] Dealing with Unchecked Checkboxes
Mihail, do u mean something like this? $pick[$i] is Checked"; } } ?> Painting Plumbing Electric Cheers, Graeme :) - Original Message - From: "Mihail Bota" <[EMAIL PROTECTED]> To: "Micah Stevens" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> 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 > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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
Re: [PHP-DB] Dealing with Unchecked Checkboxes
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