These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Create a listbox based on the contents of a text box

kukka
Registered: Jun 1 2011
Posts: 16

Hi
 
I would like to create a list box depending on the number in a text box. For example a text box allows only numbers 0, 3, 5, 7, or 10. If the user chooses 3 in the text box, the list box should display all numbers above or equal to 3 (3, 5, 7, 10). The same is true with another list box where it should display the number below or equal to 3 (0, 3). Please help me how to write this code in the list boxes.
 
Thanks

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Why use a text box if the user is only allowed to enter specific values? That's exactly what a list-box is for...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

try67
Expert
Registered: Oct 30 2008
Posts: 2398
So let's say you have 3 list-boxes. In "LB1" the user makes their selection. "LB2" shows the values larger or equal to the selected value in "LB1" and "LB3" shows the smaller values.
You set LB1 to commit the value immediately, and then use this code as the selection change script:

var lb1 = event.change;
if (lb1!="") {
var values = new Array();
for (var i=0; i < event.target.numItems; i++) {
values.push(Number(event.target.getItemAt(i)));
}
getField("LB2").clearItems();
getField("LB3").clearItems();
for (var i=0; i < values.length; i++) {
if (values[i] >= lb1)
getField("LB2").insertItemAt(values[i], values[i], -1);
if (values[i] < lb1)
getField("LB3").insertItemAt(values[i], values[i], -1);
}
}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

kukka
Registered: Jun 1 2011
Posts: 16
Thanks try67
kukka
Registered: Jun 1 2011
Posts: 16
How to use this as the selection change script. Should I use this as a javascript on mouse down event.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
In the last tab of the Properties of a list-box there's an option to execute scripts on selection change.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com