Skip to main content
Participant
August 23, 2023
Answered

Export Drop Down Value to Text - Also Be Completely Editable

  • August 23, 2023
  • 1 reply
  • 771 views

Hello, I am new to scripting and I am looking for some help to finish up a small snag in a current form.

 

I need to be able to populated text boxes based on info selected in a drop down field.  I have this working.  However, I also need the user to be able overwrite and input custom data to the drop down as well as the related text fields.  This I can not seem to figure out. 

 

With my current script, it will not allow/display text in the related text boxes once any custom data is added to the drop down.

 

Thanks for your help !

 

var selectedUnit = this.getField("Drop1").value;
if (selectedUnit=="select1") event.value = "export1";

else if (selectedUnit=="select2") event.value = "export2";
else if (selectedUnit=="select3") event.value = "export3";
else if (selectedUnit=="select4") event.value = "export4";
else if (selectedUnit=="") event.rc = (Drop1 !="");
else event.value = "";

 

 

This topic has been closed for replies.
Correct answer Nesa Nurani

I see, in that case from your script remove last 'else' and 'else if' part and that will allow you to enter text manually.

Like this:

var selectedUnit = this.getField("Drop1").valueAsString;
if(selectedUnit=="select1") event.value = "export1";
else if (selectedUnit=="select2") event.value = "export2";
else if (selectedUnit=="select3") event.value = "export3";
else if (selectedUnit=="select4") event.value = "export4";

1 reply

Nesa Nurani
Community Expert
Community Expert
August 23, 2023

Do you wish the text field to show the value selected in the dropdown field or custom value?

To show value from dropdown (including export value if any) and also allow custom text in both dropdown and text field:

1. In dropdown 'Options' tab, check 'Allow user to enter custom text'.

2. As 'Custom calculation script' of text field, use this:

 

if (event.source && (event.source.name=="Drop1"))
event.value = this.getField("Drop1").value;

 

 

Participant
August 23, 2023

Thank you so much for the quick response.

 

- I want the text field to show a value based on the drop down field (which is working).  

- But when I add custom text to the drop down, I then want to be able to add a different custom text to the text field.

- Your custom script worked, but it duplicated the drop down value into the text and did not allow custom info in the text field. 

 

Thanks again, I appreciate the support !

 

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 23, 2023

I see, in that case from your script remove last 'else' and 'else if' part and that will allow you to enter text manually.

Like this:

var selectedUnit = this.getField("Drop1").valueAsString;
if(selectedUnit=="select1") event.value = "export1";
else if (selectedUnit=="select2") event.value = "export2";
else if (selectedUnit=="select3") event.value = "export3";
else if (selectedUnit=="select4") event.value = "export4";