I'm creating a PDF form with a dropdown field (called State) with two options "Liquid" and "Dry" and a calculated text field (called Parameter). When State = "Dry" I need Parameter = "Bulk Density". When State = "Liquid" I would like the field Parameter to clear, and then allow user input.
I have this partially working with the following JavaScript entered in the field properties for the Parameter field under the Calculate tab, under Custom calculation script. However, when I select "Liquid" and manually enter data into the calculated field it clears the manually entered data.
var v = this.getField("State").valueAsString;
if (v=="Dry") event.value = "Bulk Density";
else event.value = "";
I was able to use event.rc to stop the calculation and allow user entered data, but I had to remove the else statement. The of course means when the state is switched to "Liquid" the field is not cleared for the user.
var v = this.getField("State").valueAsString;
if (v=="Dry") event.value = "Bulk Density";
event.rc = (v != "");
I've tried putting the event.rc line in the else statement, but it doesn't do anything.
var v = this.getField("State").valueAsString;
if (v=="Dry") {
event.value = "Bulk Density";}
else {
event.value = "";
event.rc = (v != "");
}
What am I missing here to combine these? Any suggestions would be greatly appreciated.