Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to: Permit a Drop-down list to receive multiple characters for searching

Avatar

Level 4
Under the Field > object palette, tick the check box titled "Allow Custom Text Entry"



Then in the exit event of the drop-down list enter the script:



var numberOfItems = 0;

var matchFound = false;



for (var nodeInList = 0; nodeInList < this.nodes.length; nodeInList++) {

if (this.nodes.item(nodeInList).className == "items") {

numberOfItems = this.nodes.item(nodeInList).nodes.length;

if (this.rawValue != null) {

for (var itemInList = 0; itemInList < numberOfItems; itemInList++) {

if (this.rawValue == this.nodes.item(nodeInList).nodes.item(itemInList).value) {

matchFound = true;

}

}

}

}

}



if (matchFound) {

// Do nothing as a match has been found

}

else {

if (this.rawValue != null) {

xfa.host.messageBox ("This entry does not match an item: " + this.rawValue);

xfa.host.setFocus ("this");

}

}

I don't know if anyone else had this as an issue for when they presented their forms to the users, but mine wanted to be able to search for "Ado" instead of just enterring "A" to search through all the A records then "D" to search through all the D records.



This code works in Reader 7 and I have also tested it in Acrobat Pro 9.



Hope it can be of use to someone else, I now feel victorious for being able to do something that you shouldn't! :D



Tom
0 Replies