I have to create a fairly large form where I would like to use FlipSwitches.
To keep the form clear, I would like to insert additional LayoutGrids into the LayoutGrid, which is defined as a form.
Now the problem is that only the "On" position of the FlipSwitch is transmitted (as RichText). Not "Off". Value is On | Off.
The transferred data looks like this:
Values submitted from website form:
Text: huhu
FlipSwitch1: $Switch1
FlipSwitch2: On
Is there a solution for this?
Here is a litte demo
Thanks in advance
Kirk
FlipSwitch On | Off Value in nested LayoutGrid
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
FlipSwitch On | Off Value in nested LayoutGrid
Last edited by KIRK on Thu Feb 08, 2024 9:13 pm, edited 1 time in total.
Re: FlipSwitch On | Off Value in nested LayoutGrid
Note that I cannot see what you have done based on the published page (HTML), because the software has thousands of options and millions of possible combinations.
So, there is no way to know which options you have used by looking at the HTML only.
To be able to help you, I need a DEMO project (.wbs file) so I can see all your settings.
Also, please include a description how to reproduce this problem.
For further details about how to share a project file, please see this FAQ:
viewtopic.php?f=10&t=82134
So, there is no way to know which options you have used by looking at the HTML only.
To be able to help you, I need a DEMO project (.wbs file) so I can see all your settings.
Also, please include a description how to reproduce this problem.
For further details about how to share a project file, please see this FAQ:
viewtopic.php?f=10&t=82134
Re: FlipSwitch On | Off Value in nested LayoutGrid
Sorry!
Here is the project
Here is the project
Last edited by KIRK on Thu Feb 08, 2024 9:13 pm, edited 1 time in total.
Re: FlipSwitch On | Off Value in nested LayoutGrid
The problem is that the flip switch is not a direct child element of the form.
In that case, the off/on trick will not work.
In that case, the off/on trick will not work.
Re: FlipSwitch On | Off Value in nested LayoutGrid
Thanks for the support.
Is there a chance that this will change in the future?
Is there a chance that this will change in the future?
Re: FlipSwitch On | Off Value in nested LayoutGrid
I will investigate if this can be improved.Is there a chance that this will change in the future?
Re: FlipSwitch On | Off Value in nested LayoutGrid
It would be great if there was a solution with LayoutGrids!
I tried it with a layer, but then elements are not realigned when they are shown or hidden via a flip switch, for example. It's not visually pretty.
Another alternative would be FlexGrid. But FlexGrid is still much more complicated and time-consuming at the moment (for me)...
I tried it with a layer, but then elements are not realigned when they are shown or hidden via a flip switch, for example. It's not visually pretty.
Another alternative would be FlexGrid. But FlexGrid is still much more complicated and time-consuming at the moment (for me)...
Re: FlipSwitch On | Off Value in nested LayoutGrid
Note that it works with Layout Grids, but not with nested grids.
Re: FlipSwitch On | Off Value in nested LayoutGrid
Yes, I know that. Thanks.
It is a fairly extensive form, so I would like to add some structure and clarity.
Some form fields are longer (text areas) others are very short (flip switch with a 1 word label). In some cases I would like to arrange the short fields next to each other. For the elements that are arranged next to each other, I work with nested LayoutGrids.
Part of the form can be seen in the picture (first draft).
Or is there an other/better way?
It is a fairly extensive form, so I would like to add some structure and clarity.
Some form fields are longer (text areas) others are very short (flip switch with a 1 word label). In some cases I would like to arrange the short fields next to each other. For the elements that are arranged next to each other, I work with nested LayoutGrids.
Part of the form can be seen in the picture (first draft).
Or is there an other/better way?
Re: FlipSwitch On | Off Value in nested LayoutGrid
You can also flexbox for this. However, you will still need nesting because a container can only alignment its elements in one direction.
Or else use a flexgrid.
Or else use a flexgrid.
Re: FlipSwitch On | Off Value in nested LayoutGrid
If you are prepared to add an HTML element on the page and add a little bit of JavaScript there is a way to provide what you want with nested LayoutGrids. There are probably other solutions but this works for my project.
References > formData in the developer.mozilla.org pages points the way.
Note for the below code: 'form' is the name you've given your form. Change to suit. Both 'agerange' and 'tellme' are the names of the FlipSwitch elements in the form. Adjust / add / remove as required. console.log() provides diagnostics while testing your page and not required when the form is working as intended. e.preventDefault() stops the Submit button from firing while testing, if desired remove the comment //. Make sure you have it commented for the live page/form.
Add the following to your HTML element:
References > formData in the developer.mozilla.org pages points the way.
Note for the below code: 'form' is the name you've given your form. Change to suit. Both 'agerange' and 'tellme' are the names of the FlipSwitch elements in the form. Adjust / add / remove as required. console.log() provides diagnostics while testing your page and not required when the form is working as intended. e.preventDefault() stops the Submit button from firing while testing, if desired remove the comment //. Make sure you have it commented for the live page/form.
Add the following to your HTML element:
Code: Select all
<script>
// grab reference to form
const formElem = document.querySelector("form");
// submit handler
formElem.addEventListener("submit", (e) => {
// on form submission, prevent default
// e.preventDefault();
console.log(formElem.querySelector('input[name="agerange"]'));
console.log(formElem.querySelector('input[name="tellme"]'));
// construct a FormData object, which fires the formdata event
const formData = new FormData(formElem);
// formdata gets modified by the formdata event
console.log(formData.get("agerange"));
console.log(formData.get("tellme"));
});
// formdata handler to retrieve data
formElem.onformdata = (e) => {
console.log("formdata fired");
// modifies the form data
const formData = e.formData;
if(formData.get("agerange") == null) formData.set("agerange", "NO");
if(formData.get("tellme") == null) formData.set("tellme", "NO");
formElem.submit();
};
</script>