Copy link to clipboard
Copied
Hi,
I was wondering if there's a way to change the format of a form field based on the selection of another form field (drop down).
I'm a newbie with this, and I figured the community would be able to solve my question:
I have a dropdown field called "Type", with 2 options (Clearance and Regular).
I want to change the format of a field named "Price" to 2 different custom formats depending on the selection of the dropdown.
As for now, I have a custom validation text in the "Type" field as follows:
if(event.value == "Regular"){
this.getField("Price").textColor = color.black
}else if(event.value == "Clearance"){
this.getField("Price").textColor = ["RGB",237/255,28/255,36/255]
}
I also have a custom format Script for the "Price" field as:
var str = event.value;
if(event.value){
var spans = new Array();
spans[0] = new Object();
spans[0].text = "was $";
spans[1] = new Object();
spans[1].text = str;
spans[1].strikethrough = true;
event.richValue = spans;}
What I wanted to do was tweak either one of the scripts so that the text preceding the entered value in the "Price" field to be "was $" when "Clearance" is selected in the dropdown, but change it to be "compare at $" when "Regular" is selected.
Any help is appreciated.
Have something to add?