Copy link to clipboard
Copied
Hey all,
I'm working on a project where I need the choice on a dropdown menu to reveal and hide certain fields. I wrote a code that works just fine for text fields but will not work with an image field. Code below:
switch(event.value) {
case "Option A":
this.getField("Text 1").display=display.visible;
this.getField("Text 2").display=display.hidden;
this.getField("Image 1").display=display.visible;
this.getField("Image 2").display=display.hidden;
break;
case "Option B":
this.getField("Text 1").display=display.hidden;
this.getField("Text 2").display=display.visible;
this.getField("Image 1").display=display.hidden;
this.getField("Image 2").display=display.visible;
break;
}
With this code applied to my Dropdown field my Text fields swap just fine, but the Images remain visible no matter the dropdown option chosen. Another thing I noticed is that whenever I rename an Image field it becomes a Button automatically. I thought that might be the issue, but I adjusted the code for the auto-populated Image field name and still had the same issue. Are Images and/or Buttons unable to be hidden/revealed, or is there a setting I am missing somewhere?
Cheers!
Copy link to clipboard
Copied
Check the Javascript console for errors.
Copy link to clipboard
Copied
Hi Bernd,
I am getting this from the Debugger:
SyntaxError: syntax error
1:Console:Exec
undefined
However, when I remove the image code and just include the text field codes in the debugger I get the same error message. But if I utilize the text-field-only code in my Custom Calculation Script, the text fields behave exactly as intended when the different dropdown options are selected.
Copy link to clipboard
Copied
Add the code again, change the value of the field and then check the JS Console once more.
That error is from something you executed from the Console. It has nothing to do with it.
Copy link to clipboard
Copied
Sorry, still very new to this. What do I need to chance the fields to? I only have 5 fields in the document (dropdown, x2 text and x2 image). With only the text fields utilized (see code below) there aren't any other available fields for troubleshooting other than the image fields, which were the intial problem. And this code works fine in the Custom Calculation Script. I just can't get the same results from: this.getField("variable").display=display.hidden; if the variable is an image or a button field.
switch(event.value) {
case "Option A":
this.getField("Text 1").display=display.visible;
this.getField("Text 2").display=display.hidden;
break;
case "Option A":
this.getField("Text 1").display=display.hidden;
this.getField("Text 2").display=display.visible;
break;
}
Copy link to clipboard
Copied
Please follow our instructions. Try the full code and check for errors.
Copy link to clipboard
Copied
I am suffering from exactly the same symptoms.
Only the image field is not hidden.
var PAPA1 = this.getField ("PAPA_1"); //Text Field
var MAMA1 = this.getField ("MAMA_1"); //Image Field
PAPA1.display = display.hidden; //It disappears from the screen.
MAMA1.display = display.hidden; //It doesn't disappear from the screen.
No error appears here.
It just doesn't disappear.
Copy link to clipboard
Copied
Can you share the file with us?