Copy link to clipboard
Copied
asking if a javascript can be written to unhide and select a field based on a selection from a dropdown list?
Copy link to clipboard
Copied
Yes, by using this code:
var otherField = this.getField("2nd Lock Template");
if (event.value=="Other (Complete Below)") {
otherField.display = display.visible;
otherField.readonly = false;
otherField.setFocus();
} else {
otherField.display = display.hidden;
otherField.readonly = true;
otherField.value = "";
}
By the way, I noticed that in your code there are various problems. Do not use Word for editing code! Only use a plain-text editor, like Notepad.
Copy link to clipboard
Copied
JavaScript can "unhide" a field, yes, but I'm not sure what you mean by "select" it... Please clarify.
Copy link to clipboard
Copied
I have several dropdown lists on my form, for some of the selections I would like to have another field unhide so the operator can type in some information. However most of the answers do not require operator information so I don’t want the hidden field to show if those answers are selected.
Copy link to clipboard
Copied
So the visibility of this field should be dependent on the value of multiple fields? That's a bit tricky... Under what circumstances should the field be visible then?
Copy link to clipboard
Copied
The list will contain standard choices, but one choice will be “Other”. If that choice is selected then I want the control to go to another text field that the operator can type in their answer. So for instance there will be 5 standard choices and one that is “Other”. When a standard choice is selected we’ll go to the next item, when “Other” is selected we’ll unhide a text field and send control there.
Copy link to clipboard
Copied
OK, that's more clear. As the custom Validation script of the drop-down field enter this code:
var otherField = this.getField("OtherText");
if (event.value=="Other") {
otherField.readonly = false;
otherField.setFocus();
} else {
otherField.readonly = true;
otherField.value = "";
}
Adjust the field name in the code as required, and make sure to tick the option to commit the selected value of the drop-down field immediately, under its Properties - Options tab.
Copy link to clipboard
Copied
I used the following code:
Var otherField = this.getField(“2nd Lock Template”);
If (event.value==”Other (Complete Below)” {
otherField.readonly = false
otherField.setFocus();}
else
otherField.readonly = true
otherField.value = “”;}
Is there any way I can keep “2nd Lock Template” hidden and unhide in this code?
Thanks
Tom
Copy link to clipboard
Copied
Yes, by using this code:
var otherField = this.getField("2nd Lock Template");
if (event.value=="Other (Complete Below)") {
otherField.display = display.visible;
otherField.readonly = false;
otherField.setFocus();
} else {
otherField.display = display.hidden;
otherField.readonly = true;
otherField.value = "";
}
By the way, I noticed that in your code there are various problems. Do not use Word for editing code! Only use a plain-text editor, like Notepad.
Copy link to clipboard
Copied
That’s working fine. Thanks for the help. Also, I entered the code using Adobe.
Tom

