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

JS help in LCD please

Zeynep
Registered: Nov 29 2008
Posts: 21
Answered

Hi,

I'm pretty new with Designer and javascript and building my first dynamic form.

I have several lists of comments where the user is supposed to scroll down and pick one, but I can't use dropdown lists, because the comments are too long to fit in them.

So, I'm trying to use a button to rotate the comments in an expandable text field with every click.

I created an array, like:

var com = new Array() ;

com[0] = "Click button to select commendation";
com[1] = "List item 1...";
com[2] = "List item 2 ....";
com[3] = etc.

and tried a simple script with a counter in the 'click' event:

var btn = "0";
myButton.rawValue = btn;
myTextField.rawValue = com[btn];
btn++;

which didn't do anything. So I tried a loop:

for (var nCount = 0; nCount < 20; nCount++)
{
s4l1a.rawValue = com[nCount]
break;
}

But with the "break" it stops at the 1st item and without it, it scrolls straight to the end.

Are my scripts totally off the mark? Is there any other way to do this, should I be using other objects?

Any advice would be soo appreciated.
Thanks,

Zeynep

My Product Information:
LiveCycle Designer, Windows
formman
Registered: Jul 17 2008
Posts: 44
Zeynep,

I think that I have a solution to your problem. Below is some JavaScript that will allow you to cycle through all the selections you need for a specific text field.

You will also have to create a Form Variable (in this case it is oCycle) and set its initial value to be 0 (zero).

Rick Kuhlmann
Tech-Pro



//Place in click event of a button
//Set-up the array
var com = new Array();

com[0] = "Click button to select commendation";
com[1] = "List item 1...";
com[2] = "List item 2...";
com[3] = "ect.";

//set a counter variable to get the integer value of the Form Variable oCycle
var vInc = parseInt(oCycle.value);

//set the rawValue of the TextField to the current array item.
TextField1.rawValue = com[oCycle.value];
//increase the value of the counter variable
vInc = (vInc + 1);
//set the Form Variable equal to the counter variable
oCycle.value = vInc+'';

//check to see if all of the values in the array have been displayed.
//If yes, the reset the Form Varialbe to "0". This allows the user to run through the list as many times as needed.
//The value in the if statement should be changed depending on how many
//items there are in the array.
if (oCycle.value > 3)
{
oCycle.value = "0";
}

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN

Zeynep
Registered: Nov 29 2008
Posts: 21
Hi Rick,

Thank you so much for your help, but I haven't been able to make it work yet.
I changed only my field name and the number of items on the list:

var oCycle = 0;
var vInc = parseInt(oCycle.value);
MyTextField.rawValue = com[oCycle.value];
vInc = (vInc + 1);
oCycle.value = vInc+'';
if (oCycle.value > 20)
{
oCycle.value = "0";
}

But now, when I press button I get the text "Empty" in my text field...?

Zeynep
formman
Registered: Jul 17 2008
Posts: 44
Jeynep,

Did you create the Form Variable (oCycle)?

Rick Kuhlmann

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN

Zeynep
Registered: Nov 29 2008
Posts: 21
Rick,

I had it as a variable in my script, I didn't know much about "form variables" so I'd missed that. Anyway, now that I did that, it's working beautifully :)

Thank you so much.

Zeynep