We're creating a form with a drop-down containing several kinds of fruits. Based on what the user selects, we'd like to have the price automatically put on the form.
Is there a way to do this?
How to use drop-down to add data to form SOLVED
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- User
- Posts: 28
- Joined: Wed Jul 22, 2020 9:01 pm
How to use drop-down to add data to form
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 6903
- Joined: Wed Mar 25, 2009 10:37 pm
- Location: Chemainus, Canada
Re: How to use drop-down to add data to form SOLVED
Hi msbask99
JavaScript required for this, and there are different ways to do it.
The simplest way can be used if the price is not to be be modified by the user. In this case you need to add a calculation script for that Price field, and in this script you need to get the selected item and return corresponding price (please note, return value is set via event.value):
if the price can be modified by the user, Keystore event for the Fruit field should be used. And the code will be different
Does that help? Can you take it from there?
JavaScript required for this, and there are different ways to do it.
The simplest way can be used if the price is not to be be modified by the user. In this case you need to add a calculation script for that Price field, and in this script you need to get the selected item and return corresponding price (please note, return value is set via event.value):
Code: Select all
var idx = getField("Fruit").currentValueIndices;
if (idx == 0)
event.value = 10.0;
else if (idx == 1)
event.value = 20.0;
Code: Select all
if (!event.willCommit)
return;
var price = 0;
if (event.value = "Oranges")
price = 10.0;
else if (event.value = "Apples")
price = 20.0;
...
if (price > 0)
getField("Price").value = price;
Does that help? Can you take it from there?
Best regards
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
-
- User
- Posts: 28
- Joined: Wed Jul 22, 2020 9:01 pm
Re: How to use drop-down to add data to form
Yes, that helps, thanks!
-
- Site Admin
- Posts: 1797
- Joined: Mon Jan 15, 2018 9:01 am