Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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

Thomas_McConnac
Level 4
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! 😄



Tom
0 Replies