Checkbox in forms
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
Checkbox in forms
I'm in need of help from the great forum gods.
I've seen a couple of old posts about this and curious if (1) has anyone gotten this to work correctly or (2) has there been an update to make it work and I'm not aware.
Situation:
Have a form with 3 check boxes: Service1, Service2, Service3
When a user checks the boxes, I understand that it turns them to the 'on' position and the value is passed.
In the Form Processor Message that is sent to the owner, I am using the variables: $Service1, $Service2, $Service3
When the form is received, if the checkbox is checked the appropriate value shows. However, the others just show the variable as above.
Is there a way to show only the variable that is checked or either show the ones that are not checked as just 'blanks'?
I would have to think there is a somewhat simple solution to this or using checkboxes would be useless unless you dont mind seeing a bunch of variables in the email. This would look bad if there were numerous checkboxes in your form.
I've seen a couple of old posts about this and curious if (1) has anyone gotten this to work correctly or (2) has there been an update to make it work and I'm not aware.
Situation:
Have a form with 3 check boxes: Service1, Service2, Service3
When a user checks the boxes, I understand that it turns them to the 'on' position and the value is passed.
In the Form Processor Message that is sent to the owner, I am using the variables: $Service1, $Service2, $Service3
When the form is received, if the checkbox is checked the appropriate value shows. However, the others just show the variable as above.
Is there a way to show only the variable that is checked or either show the ones that are not checked as just 'blanks'?
I would have to think there is a somewhat simple solution to this or using checkboxes would be useless unless you dont mind seeing a bunch of variables in the email. This would look bad if there were numerous checkboxes in your form.
- BaconFries
-
- Posts: 5640
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Checkbox in forms
In the checkbox properties what have you used in i.e. name did you include the square brackets as such [] with the text used?
Example:
Example:
Code: Select all
<input type="checkbox" name="service[]" value="service 1">
<input type="checkbox" name="service[]" value="service 2">
<input type="checkbox" name="service[]" value="service 3">
Re: Checkbox in forms
In HTML, when a checkbox it not checked the browser will not send the value to the server. So ,the post variable will not even exists on the server side.
In WWB16, there will be an option to workaround this HTML limitation.
In WWB16, there will be an option to workaround this HTML limitation.
Re: Checkbox in forms
Hi Ron (crispy68),
If i have 3 check boxes set in a form, and give them each some text message in the "Value" field
Example:
Name: Checkbox1
Value: You selected Service 1
Name: Checkbox2
Value: You selected Service 2
Name: Checkbox3
Value: You selected Service 3
When checking 1 out of the 3 check boxes and submitting, I receive an email to me in testing with the values: Checkbox1: You selected Service 1
The values for the other check boxes do not appear in the email I send to myself from the form submission.
If I have a that form with a "Success" page with a text box to show the variables ($Checkbox1, $Checkbox2, $Checkbox3), this Success page will show the values for the one checked (You selected Service 1) and the other variables will appear as you stated ($Service2, $Service3) since they were not checked and the value field is not displayed but the email to myself from submission only show the value of what was in $Checkbox1.
Are wanting to send the form submission information to the person's email with the values they checked in the form or are you just displaying this in a Success page after they submit? Is it in an email to them where the variables ($Service1, $Service2, etc.) are displaying since those check boxes weren't checked or just on a Success page?
Regards,
Leo
If i have 3 check boxes set in a form, and give them each some text message in the "Value" field
Example:
Name: Checkbox1
Value: You selected Service 1
Name: Checkbox2
Value: You selected Service 2
Name: Checkbox3
Value: You selected Service 3
When checking 1 out of the 3 check boxes and submitting, I receive an email to me in testing with the values: Checkbox1: You selected Service 1
The values for the other check boxes do not appear in the email I send to myself from the form submission.
If I have a that form with a "Success" page with a text box to show the variables ($Checkbox1, $Checkbox2, $Checkbox3), this Success page will show the values for the one checked (You selected Service 1) and the other variables will appear as you stated ($Service2, $Service3) since they were not checked and the value field is not displayed but the email to myself from submission only show the value of what was in $Checkbox1.
Are wanting to send the form submission information to the person's email with the values they checked in the form or are you just displaying this in a Success page after they submit? Is it in an email to them where the variables ($Service1, $Service2, etc.) are displaying since those check boxes weren't checked or just on a Success page?
Regards,
Leo
Re: Checkbox in forms
Hey Leo,
The variable in the form submitted to the owner is showing in the email.
Here is the checkbox:
name = service1
value = Roof Repair or Service
The other 2 checkboxes are similar. When the box is checked, the value is sent with no issues. However the other 2, I receive the variable names.
Here is the set up I have for the message:
As you can see, in the email being sent it will say:
Type of Service(s) Needed:
Roof Repair or Service
$service2
$service3
The 2 variable names shouldn't show. Based on what Pablo said it kinda makes sense. My thought is there a way to define these variables as blank strings and then if they are not checked, they show a blank and if they are checked then the value is shown? Otherwise, I may have to wait patiently for WB16.
The variable in the form submitted to the owner is showing in the email.
Here is the checkbox:
name = service1
value = Roof Repair or Service
The other 2 checkboxes are similar. When the box is checked, the value is sent with no issues. However the other 2, I receive the variable names.
Here is the set up I have for the message:
As you can see, in the email being sent it will say:
Type of Service(s) Needed:
Roof Repair or Service
$service2
$service3
The 2 variable names shouldn't show. Based on what Pablo said it kinda makes sense. My thought is there a way to define these variables as blank strings and then if they are not checked, they show a blank and if they are checked then the value is shown? Otherwise, I may have to wait patiently for WB16.
- BaconFries
-
- Posts: 5640
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Checkbox in forms
Evening crispy68 reading more on this I believe what you are after is something like this
Example:
Name: Checkbox1
Value: You selected Service 1
Name: Checkbox2
Value: You selected Service 2
Name: Checkbox3
Value: You selected Service 3
Correct? if so then as Pablo's reply there is a limitation in HTML that if any of the checkboxes are not checked then there value is not passed.
A little bit of searching I found the following:
Always Get A Checkbox $_POST Value
https://dzone.com/articles/always-get-c ... post-value
It describes how using the original input i.e. checkbox and the using a hidden checkbox and a little javascript then you should get what your after. I haven't tested this but thought I share the link. Note all credit goes to the original author.
Example:
Name: Checkbox1
Value: You selected Service 1
Name: Checkbox2
Value: You selected Service 2
Name: Checkbox3
Value: You selected Service 3
Correct? if so then as Pablo's reply there is a limitation in HTML that if any of the checkboxes are not checked then there value is not passed.
A little bit of searching I found the following:
Always Get A Checkbox $_POST Value
https://dzone.com/articles/always-get-c ... post-value
It describes how using the original input i.e. checkbox and the using a hidden checkbox and a little javascript then you should get what your after. I haven't tested this but thought I share the link. Note all credit goes to the original author.
Re: Checkbox in forms
Hi Ron
have a look at this checkbox demo I did some time ago.
Put a vaild working email in the form and see what it sends you, It sends all the checkbox data that you have ticked and forgets the rest to a text box and lays it out in html format for easy reading
https://shop.grahamscomputers.net/demo/ ... index.html
Graham
have a look at this checkbox demo I did some time ago.
Put a vaild working email in the form and see what it sends you, It sends all the checkbox data that you have ticked and forgets the rest to a text box and lays it out in html format for easy reading
https://shop.grahamscomputers.net/demo/ ... index.html
Graham
Re: Checkbox in forms
@Bacon, thanks... I will take a look at that and see if it might work.
@Graham, checked your demo and yes it did send me only the checked items. The only problem....I've yet to receive my burger!
So, is this an extension you created? I didnt see anything on your website.
@Graham, checked your demo and yes it did send me only the checked items. The only problem....I've yet to receive my burger!
So, is this an extension you created? I didnt see anything on your website.
Re: Checkbox in forms
Hi Ron,
Im trying to make it an extension, I will send you the html code and you can see what you can do with it.
Graham
P.S
im just about to go on a lunch break in 20 mins so I will send it when I get home then
Im trying to make it an extension, I will send you the html code and you can see what you can do with it.
Graham
P.S
im just about to go on a lunch break in 20 mins so I will send it when I get home then
Re: Checkbox in forms
No problem. Take your time. Enjoy your lunch. Make sure my burger is hot.
Re: Checkbox in forms
Hi Ron
Hopefully, GrahamW has a solution for you.
In the meantime, I found this which has code that may be worth a look for your checkbox issue.
https://www.formget.com/php-checkbox/
Regards,
Leo
Hopefully, GrahamW has a solution for you.
In the meantime, I found this which has code that may be worth a look for your checkbox issue.
https://www.formget.com/php-checkbox/
Regards,
Leo
Checkbox in forms
I'm wondering whether there is a workaround this problem in WB17? because its still happening for me.
Re: Checkbox in forms
Did you read the information in the help?
Help -> Contents -> Toolbox -> Checkbox
Help -> Contents -> Toolbox -> Checkbox
Re: Checkbox in forms
Hi Pablo....I did read the help file and my understanding is the following, correct me if I'm wrong.
The checkbox is set to default unchecked.
In the value field I put this off|Test
If the checkbox is checked then the output from the form is correct
If its not checked I still get the output as $example not what i expected as Test because its not checked.....in reality Id like it to be blank
Have I misinterpreted the help file?
The checkbox is set to default unchecked.
In the value field I put this off|Test
If the checkbox is checked then the output from the form is correct
If its not checked I still get the output as $example not what i expected as Test because its not checked.....in reality Id like it to be blank
Have I misinterpreted the help file?
Re: Checkbox in forms
When you use the workaround (ON | OFF), then
ON will be use when the checkbox is checked.
OFF will be used when the checkbox is unchecked.
ON will be use when the checkbox is checked.
OFF will be used when the checkbox is unchecked.
Code: Select all
if (!isset($_POST['Checkbox1']))
{
$_POST['Checkbox1'] = "off";
}
Re: Checkbox in forms
So my understanding is correct? And yet the output is not changing?
Checkbox is default set to off
Value is set to OFF | Test
So in my example if checkbox is unchecked then output should be outputting Test?
Do I have to copy the script you provided below?
Thanks
Checkbox is default set to off
Value is set to OFF | Test
So in my example if checkbox is unchecked then output should be outputting Test?
Do I have to copy the script you provided below?
Thanks
Pablo wrote: ↑Fri Jun 10, 2022 8:13 am When you use the workaround (ON | OFF), then
ON will be use when the checkbox is checked.
OFF will be used when the checkbox is unchecked.
Code: Select all
if (!isset($_POST['Checkbox1'])) { $_POST['Checkbox1'] = "off"; }
Re: Checkbox in forms
CorrectSo in my example if checkbox is unchecked then output should be outputting Test?
NoDo I have to copy the script you provided below?
Without seeing your exact settings it will be difficult to help you.
Re: Checkbox in forms
Thanks Pablo, I have attached my page, I have stripped everything from it and left one layout grid with checkboxes.
Only the first checkbox has the value as off | Test others I left as default.
https://www.dropbox.com/s/gv0u5oq27x790yv/test.wbs?dl=0
I look forward from hearing from you.
Only the first checkbox has the value as off | Test others I left as default.
https://www.dropbox.com/s/gv0u5oq27x790yv/test.wbs?dl=0
I look forward from hearing from you.
Re: Checkbox in forms
In your case, it does not work because you are using nested layout grids.
This feature only works if the checkbox is a direct child element of the form.
This feature only works if the checkbox is a direct child element of the form.
Re: Checkbox in forms
Thanks Pablo....I'm assuming it also won't work if I use a flex grid?
Re: Checkbox in forms
It works as long as the checkbox is a direct child element of the layout grid or flexgrid.