How to use drop-down to add data to form  SOLVED

A picture is worth a thousand words. We have created some pdfs tutorials showing common tasks.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
msbask99
User
Posts: 27
Joined: Wed Jul 22, 2020 9:01 pm

How to use drop-down to add data to form

Post by msbask99 »

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.

Image

Is there a way to do this?
Attachments
untitled.png
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6835
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: How to use drop-down to add data to form  SOLVED

Post by Paul - Tracker Supp »

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):

Code: Select all

var idx = getField("Fruit").currentValueIndices;
if (idx == 0)
  event.value = 10.0;
else if (idx == 1)
  event.value = 20.0;
if the price can be modified by the user, Keystore event for the Fruit field should be used. And the code will be different

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
msbask99
User
Posts: 27
Joined: Wed Jul 22, 2020 9:01 pm

Re: How to use drop-down to add data to form

Post by msbask99 »

Paul - Tracker Supp wrote: Wed Feb 23, 2022 4:54 pm Does that help? Can you take it from there?
Yes, that helps, thanks!
User avatar
Dimitar - Tracker Supp
Site Admin
Posts: 1778
Joined: Mon Jan 15, 2018 9:01 am

How to use drop-down to add data to form

Post by Dimitar - Tracker Supp »

:)
Post Reply