I have created a form which asks some questions of the user. For aesthetic and usability reasons I have used a button which, onClick, affects the value of a hidden dropdown.
$w(“#dropdown1”).value = “Yes”;
When submitting the form, the dropdown value does not write to the dataset and field to which it is connected.
If I unhide the dropdown, then I can see the value is being affected by the button as intended.
If I unhide the dropdow and select the value directly in the dropdown box then the issue disappears and the value writes to the dataset.
Can anyone shed any light on this?
Hey
After you have clicked a button how to you do in your code? Do you use code or just connect Dropdown to dataset? I believe you will be better of if you use code when the button is clicked to set the value to the dataset instead of going for the Dropdown solution.
Lets says your dataset is named dataset1.
In the button_onClick event code do this.
$w("#dataset1").setFieldValue("fieldKey-in-dataset","YES or value here");
Using setFieldValue you set the field directly to current item in dataset1 which is a better solution for you.
Further to this, i’m using the sendGrid method described in this article:
For each of the questions the user is answering with a button, I would like to send their selections in the email body. An example would be:
const body = `Name: '${$w(“#ECname”).value}
\rQuestion 1: Answer to Question 1 }
If I want to send the user’s selection for question 1 (i.e. if they pressed the Yes button then “Yes”), how could this be achieved as I don’t have this value stored until dataset is saved?
Would I need to define a variable when the user presses the button and then reference the variable in the email boday?
Managed as described above by setting variables and solved issue
Post as new questiom please