Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic and conditional form construction

New Here ,
Jan 19, 2021 Jan 19, 2021

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

TOPICS
PDF forms
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 19, 2021 Jan 19, 2021

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 20, 2021 Jan 20, 2021

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 20, 2021 Jan 20, 2021

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 20, 2021 Jan 20, 2021

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 20, 2021 Jan 20, 2021

Use it as 'Custom keystroke script' or 'custom validation script' or 'custom calculation script'.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2021 Jan 22, 2021

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 22, 2021 Jan 22, 2021

What do you use to make "Text1" visible? another script somewhere?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2021 Jan 22, 2021

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")

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2021 Jan 22, 2021
LATEST

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines