Checkbox?

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
IMPORTANT NOTE!!

DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.



PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
Post Reply
peters
 
 
Posts: 65
Joined: Thu Sep 28, 2023 12:29 pm

Checkbox?

Post by peters »

I am trying to implement a checkbox in a form. I have tried: Bootstrap, Default and jQuery UI. I want to use Bootstrap due to the look and low impact on resources + it said in help this style is actively being developed.
Also read the help in QBB on checkboxes, it says if you want to set the value to unchecked enter ON|OFF in the value and I have the default set to not checked.
If I check the checkbox things work as expected with no errors on submit. However, if I leave the checkbox unchecked I get the following error: PHP Warning: Undefined array key "pkupUrgent" in C:\inetpub\wwwroot\Pickups\Cus-Pickup1.php on line 32
pkupUrgent is the ID for the checkbox.
I went out in Google and see many others have this exact error. I have read through quite a few threads and so far I do not see any solution to this error. Is there something you have to do in WWB as far as settings for the checkbox to get it to work when being unchecked?
Many thanks in advance for anyone that can assist!
Pete,
User avatar
jerryco
 
 
Posts: 916
Joined: Fri Mar 27, 2009 2:42 pm
Location: Purmerend, Holland

Re: Checkbox?

Post by jerryco »

For completeness sake, can you see what is on this line in the file?
PHP Warning: Undefined array key "pkupUrgent" in C:\inetpub\wwwroot\Pickups\Cus-Pickup1.php on line 32
// Love is the acceptance of nothing / Account age is no guarantee of efficiency ;-) ->

Above, Beyond, and @wwonderfull! <- Genuinely helps you with a powered up site that counts! Four Times Excellence!
peters
 
 
Posts: 65
Joined: Thu Sep 28, 2023 12:29 pm

Re: Checkbox?

Post by peters »

Hi Jerryco,
Of course I can see what is on that line - lol
I found the work-a-round on this checkbox issue.
If you don't check the checkbox the code does not recognize it and post nothing into the mySQL backend table.
I set the value to ON|OFF as I mentioned and then set the initial value to not checked as I mentioned.
Then in my PHP code when I submit I need the following code where my checkbox ID is: pkupUrgent
if (!isset($_POST['pkupUrgent']))
{
$_POST['pkupUrgent'] = "off";
$pkupUrgent = "off";
}
else
{
$_POST['pkupUrgent'] = "on";
$pkupUrgent = "on";
}
I needed to set the memvar $pkupUrgent to off or on as later in the PHP I am doing an INSERT statement and using this memory variable $pkupUrgent as my INSERT VALUE statement for the checkbox field back into mySql Server. If I leave the $pkupUrgent memvar unassigned my INSERT statement errors out with an unknown value.
Issue is now resolved and working 100% if I check off or uncheck the checkbox.

Pete,
Last edited by peters on Tue Nov 21, 2023 7:18 pm, edited 2 times in total.
User avatar
Pablo
 
Posts: 23613
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Checkbox?

Post by Pablo »

I set the value to ON|OFF as I mentioned and then set the initial value to not checked as I mentioned.
This only works if you use the built-in form processor script. This is not a standard HTML feature

If you need further assistance then please share a DEMO project so I can see what you have done.

To be able to help you, I need a DEMO project (.wbs file) so I can see all your settings.

I do not need the complete project because that will only take more time to figure out what you have done.
Basically, I just need a small project with one page and object(s) that are relevant to your question.

For further details about how to share a project file, please see this FAQ:
viewtopic.php?f=10&t=82134
peters
 
 
Posts: 65
Joined: Thu Sep 28, 2023 12:29 pm

Re: Checkbox?

Post by peters »

Thanks very much Pablo. I got it figured out. I was not aware of the fact that a browser does not submit any value for an unchecked checkbox. Once I saw this on: https://stackoverflow.com/questions/798 ... checkboxes
Answer 6 : I then knew what I was looking at and simply added in the code to cover this issue. Boy, lots of folks ran into this issue and it somehow seems strange that an unchecked checkbox would be totally ignored, but apparently that is exactly the case.

Pete,
Post Reply