Skip to main content
Known Participant
November 29, 2022
Question

Allowing a user to enter text into a dropdown list and have the text saved to the list?

  • November 29, 2022
  • 5 replies
  • 1619 views

I  am creating a recipe pdf file and I have created a dropdown list to allow a user to select the type of recipe to fill the in the dropdown text box ie; main course, dessert, appetizer and so on.

My question is if in the dropdown list I check the opiton to "allow user to enter custom text" and the user enters a text such as "pasta", can that text be saved in the dropdown list after the user has entered the text?

I have tried different ways but the text is never saved into the dropdown list.

Thanks for your help.

5 replies

Participating Frequently
July 21, 2025

Easiest way is to copy/paste what you want to show in the drop down list then ADD (like you would for a new item) to the drop down list. however, I do not know how many characters will be allowed in a drop down list.  

bebarth
Community Expert
Community Expert
December 6, 2022

...and as ls_rbls mentioned, if you add the ability to add an item you must add the ability to remove it:

 

 

var theList=[];
for (var i=0; i<event.target.numItems; i++) theList.push(event.target.getItemAt(i))
if (this.getField("chkBox").value=="Off") {
	var found=0;
	for (var i=0; i<theList.length; i++) {
		if (theList[i]==event.value) {
			found++;
			break;
		}
	}
	if (!found) {
		theList.push(event.value);
		event.target.setItems(theList);
		event.target.value=event.value;
	}
} else {
	for (var i=0; i<theList.length; i++) {
		if (theList[i]==event.value && i!=0) {
			theList.splice(i, 1);
			this.getField("chkBox").value="Off";
			break;
		}
	}
	event.target.setItems(theList);
}

 

 

@+

bebarth
Community Expert
Community Expert
December 6, 2022

Hi,

Here is an On Blur Action script:

var theList=[];
for (var i=0; i<event.target.numItems; i++) theList.push(event.target.getItemAt(i))
var found=0;
for (var i=0; i<theList.length; i++) {
	if (theList[i]==event.value) {
		found++;
		break;
	}
}
if (!found) {
	theList.push(event.value);
	event.target.setItems(theList);
	event.target.value=event.value;
}

 @+

ls_rbls
Community Expert
Community Expert
December 5, 2022

++Adding to the topic,

 

If you will enable the option for users to type in the name of a desired item in a combobox, and add that item into the existing list, you must employ a JavaScript script. In which case, you'll also need to provide the ability for the user to delete the new entries if they are mispelled or have errors after they hit enter, for example. Otherwise the list will display a bunch of unnecessary added items (making it a mess).

 

The best way to do this is to create a predefined list of recipe names that will remain always available and append the new added items to the end of that pre-defined list. 

 

Would you be able to share an example of your PDF?

AkanchhaS8194121
Legend
December 5, 2022

Hi @wislndixie9724896 

 

Thanks for reaching out.

If you are following all the steps as it is and the "Allow user to enter the custom text" dialog is checked under the properties, then it should work.

Have you tried working on it at your end, can you enter the custom text? How the users have been opening the form, it also depends on that.

We have a similar discussion here, where this issue has been addressed and resolved. Please have a look 

https://community.adobe.com/t5/acrobat-discussions/need-help-with-a-dropdown-list-user-cannot-enter-own-text/td-p/10568479 

 

Thanks,

Akanchha