Copy link to clipboard
Copied
Hello.
I am a very new user with basic capabilities. I would like to create a form (Process checksheet) within which there are some conditional elements.
Assume each checksheet row contains 1 dropdown ("Dropdown1") with three options (Yes, No, Not applicable) and the starting state / default for each dropdown is "No". And an addition text box (Textbox1" for more information if the user selects "No".
What I would ideally like is: When a user selects either "Yes" OR "Not applicable" from Dropdown1 then the dropdown on the second row ("Dropdown2") becomes visisble. If the user selects "No" from Dropdown1 the Textbox1 becomes visible. The user then has to enter "text" before Dropdown2 is made visible. I understand this is probably best solved using JavaScript, which I know nothing about. But I presume I would "insert" two elements of script. One part in the Actions Property tab of Dropdown 1 (to 'show' either Dropdown2 or Textbox1) and the second part in the Actions Property tab of Textbox1 (for the text present check to 'show' Dropdown").
Thank you in advance and kind regards
Copy link to clipboard
Copied
This can be done easily with a script to show hide fields depending on values, but just to clarify something.
When you say 'textbox' you mean 'text field'?
You write that if user select 'No', textbox ( I assume it's text field) becomes visible and you said that 'No' is default value so text field is already visible? Does 'textfield' goes hidden when other options in dropdown are selected?
Copy link to clipboard
Copied
Thank you for responding.
Yes, I have just checked in the forms editor element properties and it is a Textfield, Confusingly I just labeled it TextBox.
I see your point. Perhaps If we introduced a forth drop down option, " " (a space) as the default, then the "textfield" is not intiaily visible and only becomes so on selection of "No".
Kind regards
Copy link to clipboard
Copied
You can use this code in 'Dropdown1' field and don't forget to tick 'commit selected value immediately' in dropdown field options tab:
this.getField("Text1").display = event.value == "No" ? display.visible : display.hidden;
this.getField("Dropdown2").display = (event.value == "Yes" || event.value == "Not applicable") ? display.visible : display.hidden;
Copy link to clipboard
Copied
Thank you Nesa,
I have managed...to get the two suplimentry items(Text1 and Dropdown2) opening / closing according to the selected value of Dropdown1. I can only really get it working satisfactorily with 'on Blur' and to an extent 'on focus'. The mouse enter/exit/up/down don't appear to activate the script. I did selected 'commit selected value immeadiately' but didn't notice an immeadiately obvious change when it was deselected. Thank you ever so much for your help and have a great day.
Copy link to clipboard
Copied
Use it as 'Custom keystroke script' or 'custom validation script' or 'custom calculation script'.
Copy link to clipboard
Copied
Nesa,
Do you have any thoughts on how I could:
1) Check the contents of Text1 if and when it is made visible to see if there is any alphanumeric text present and if there is make dropdown2 visible.
2) Reset the contents of Text1 when either Dropdown2 is made visible or Text1 is initially opened.
Kind regards
Copy link to clipboard
Copied
What do you use to make "Text1" visible? another script somewhere?
Copy link to clipboard
Copied
this.getField("TextBox2").display = event.value == "No" ? display.visible : display.hidden;
this.getField("Dropdown2").display = (event.value == "Yes" || event.value == "Not applicable") ? display.visible : display.hidden;
Placed in the custom validation script of "Dropdown1")
Copy link to clipboard
Copied
Reading accross various threads I have added:
this.getField("TextBox2").value = "";
this.getField("TextBox2").display = event.value == "No" ? display.visible : display.hidden;
this.getField("Dropdown2").display = (event.value == "Yes" || event.value == "Not applicable") ? display.visible : display.hidden;
Which appears to clear the TextBox2 each and everytime it is 'opened / closed' through Dropdown1
Find more inspiration, events, and resources on the new Adobe Community
Explore Now