Copy link to clipboard
Copied
Working with a few dropdowns, one is always visible and when a value is selected in it, another field becomes visible. How can I tell the invisible dropdowns to return to a default value if they're invisible?
if (this.getField("Make").value == "Chevrolet") this.getField("Chevrolet Models") display = display.visible;
else if (this.getField("Make").value != "Chevrolet") this.getField("Chevrolet Models") display = display.hidden;
That's all I'm working with so far. It'll hide the field of course but if a value is selected in the newly visible field it will remain selected when the field is invisible.
Halp plz!
Copy link to clipboard
Copied
First make sure that both dropdown menu fields are set to commit selected value immediately and disable to allow users to enter custom text.
Also add a space entry in the dropdown options lists.
This is key in order to be able to use the "this.resetForm()" function or to use a condition that will aid in having the Chevrolet Models dropdown appear as null or blank if "Chevrolet" is selected in the Make dropdown. menu field.
See slide:
Note in the slide above that I have selected the blank entry as my first choice before closing the dialogue box. If you don't do this , when you reset this field, it will always default to whatever you had selected in it before you close the Properties dialoguw box.
For the script portion of this exercise, I am using the following as custom calculation script in the "Make" dropdown menu field:
if (event.value == "Chevrolet") {
this.getField("Chevrolet Models").display = display.visible;
}
if (event.value !== "Chevrolet") {
this.getField("Chevrolet Models").display = display.hidden;
if (this.getField("Chevrolet Models").value !=="") {this.getField("Chevrolet Models").value =" ";}
// or you can use ---->>>> this.resetForm(["Chevrolet Models"]);
}
Note also that in the script that you've posted earlier there is a space before the word "display:
It should be a single phrase connected by a period( ".") soon after the prenthesis " ) " and before the word "display", like this:
Copy link to clipboard
Copied
First make sure that both dropdown menu fields are set to commit selected value immediately and disable to allow users to enter custom text.
Also add a space entry in the dropdown options lists.
This is key in order to be able to use the "this.resetForm()" function or to use a condition that will aid in having the Chevrolet Models dropdown appear as null or blank if "Chevrolet" is selected in the Make dropdown. menu field.
See slide:
Note in the slide above that I have selected the blank entry as my first choice before closing the dialogue box. If you don't do this , when you reset this field, it will always default to whatever you had selected in it before you close the Properties dialoguw box.
For the script portion of this exercise, I am using the following as custom calculation script in the "Make" dropdown menu field:
if (event.value == "Chevrolet") {
this.getField("Chevrolet Models").display = display.visible;
}
if (event.value !== "Chevrolet") {
this.getField("Chevrolet Models").display = display.hidden;
if (this.getField("Chevrolet Models").value !=="") {this.getField("Chevrolet Models").value =" ";}
// or you can use ---->>>> this.resetForm(["Chevrolet Models"]);
}
Note also that in the script that you've posted earlier there is a space before the word "display:
It should be a single phrase connected by a period( ".") soon after the prenthesis " ) " and before the word "display", like this:
Copy link to clipboard
Copied
Small correction. It's not:
this.reset.Form(["Chevrolet Models"]);
But:
this.resetForm(["Chevrolet Models"]);
Copy link to clipboard
Copied
Oooh! sorry about that I missed that typo. Thank you!
Copy link to clipboard
Copied
I just fixed it.
Copy link to clipboard
Copied
This worked prefectly! Thank you so much for your help! I saw your note about the typo and went over the code very carefully to see if there were any other inconsistencies- found 2.
if (event.value == "Chevrolet") { this.getField("Chevrolet Models").display = display.visible; }
if (event.value !== "Chevrolet") { this.getField("Chevrolet Models").display = display.hidden; }
if (this.getField("Chevrolet Models").value !=="") { this.resetForm(["Chevrolet Models"]); }
I added a } at the end of the second if statement and a space between the last { and this.resetForm. I'm still learning all this as I go so I have no idea if they're even relevant changes.
Thanks again! This solves a ton of current and anticipated headaches!