Skip to main content
Participant
July 31, 2023
Question

Auto populate item description and price from drop down menu

  • July 31, 2023
  • 1 reply
  • 529 views

I have a quote form that includes item#, Description, Item Qty, Item Price, and Total

I auto populate my description from entering information in the Export value in the drop down menu under Item#. For the Description, I enter java script event.value=this.getField("Item1").value; in Custom Calculation Script under the Calculate tab.

I need to do 2 things- 1. Allow custom text in the Description. 2. Autopopulate Price Ea. based on drop down selection. 

This topic has been closed for replies.

1 reply

S_S
Community Manager
Community Manager
July 31, 2023

Hi @cynthiac80143548,

 

Hope you are doing well. Thank you for writing in!

 

You might want to try the below script once: 

function autoPopulateItemDescriptionAndPrice(dropDownField, descriptionField, priceField) {
  // Get the value of the drop down field
  var selectedValue = dropDownField.value;

  // Get the description and price for the selected value
  var description = "No description";
  var price = 0;

  switch (selectedValue) {
    case "Item 1":
      description = "This is item 1";
      price = 100;
      break;
    case "Item 2":
      description = "This is item 2";
      price = 200;
      break;
    case "Item 3":
      description = "This is item 3";
      price = 300;
      break;
    default:
      break;
  }

  // Set the description and price fields
  descriptionField.value = description;
  priceField.value = price;
}

// Get the drop down field, description field, and price field
var dropDownField = this.getField("DropdownField");
var descriptionField = this.getField("DescriptionField");
var priceField = this.getField("PriceField");

// Auto populate the description and price fields
autoPopulateItemDescriptionAndPrice(dropDownField, descriptionField, priceField);

 

Note: I am not an expert in scripting, which may or may not work.

 

-Souvik

 

 

try67
Community Expert
Community Expert
August 1, 2023

- There's no need to pass the dropdown field as a variable. You can just pass the selected value directly, using event.value.

- This code, if used, should be done from the drop-down's custom Validation event. It's very important to say where the code should be used, as it won't work the same from another context.