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
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