Reputation: 551
I am trying to do a simple thing, but not sure how to do it in Google App Maker
All I want to do is:
Create a radio button 3 values (Employee
, Contractor
, Vendor
) where Employee
should be selected by default.
Based on what is selected, I want to put some logic such as if the Employee
is selected, then the discount will be 15% etc.
So I can display the result at the end of the quiz showing how much discount you would get based on your answers.
How can i achieve this?
Upvotes: 0
Views: 431
Reputation: 532
If you just want to read a value from a radio button and change a label based on that, it's pretty easy. I wasn't sure what you'd want your data structure to look like from the questions. If you want to do a longer form or do calculations based on this you'll need to store the discount as an variable (or in your datastore)
I modified the Hello App Maker code and just replaced the name field with an options selection, and put "Employee" and "other" as options. Then you can replace the submit button code with the following:
var options = app.pages.Main.descendants.radio;
var outputWidget = app.pages.Main.descendants.Output;
if (options.value == 'Employee') {
outputWidget.text = '15% discount';
} else {
outputWidget.text = 'no discount!';
}
Upvotes: 1