


Hi All.
I create global variable Names with values: John, Bill.
Now I would like to compare global variable to entered value in TextField. For instance:
if (TextField1.rawValue == Global.John) {
TextField2.presence = "hidden";
}
How to do that?
Thanks.
Views
Replies
Sign in to like this content
Total Likes
Hi,
It should work as you have written as long as your script object is named Global and your variable is named John.
You would put the if statement into TextField1's Exit event. When the field is exited, if there is a match with the variable, TextField2 will be hidden.
In my example, if i put 1 in the textfield and then exit it, textfield2 is hidden as textfield1 equals the Global.John variable contents.
Before Exiting
After Exiting
Views
Replies
Sign in to like this content
Total Likes
Hi MinusZero. Thanks for replay.
In your example, if I understood correct, you insert Script Object named Global. But I asked about global variable. In my form I created global variable NAMES with values John,Bill. That is like global array.
Please, let me know how can i declare a array that is GLOBAL. If to say Names[0]. Is that John?
Thanks.
Views
Replies
Sign in to like this content
Total Likes
I create global variables like this.
Right click the Form in the Hierarchy View and Select Insert Script Object
Rename the script object Global
While selected, open the code view and write your variables
The variables are referenced by Global.John etc
You can also change the global variable by referencing it in this way.
Views
Replies
Sign in to like this content
Total Likes
Here is a simple tutorial
I have a script object with the John variable with a value of 1
I have a numeric field which in it its initialise event it has
form1.#subform[0].NumericField1::initialize - (JavaScript, client)
this.rawValue = Global.John; //display the variable when the form starts
I have a button which adds 1 to the global variable John when clicked.
form1.#subform[0].Button1::click - (JavaScript, client)
Global.John = Global.John + 1; //add 1 to the variable everytime it is clicked.
I have another numericField and i have a second button which when clicked sends the new John variable value to the numericField.
form1.#subform[0].Button2::click - (JavaScript, client)
NumericField2.rawValue = Global.John;
When form is started, Global.John is displayed in the NumericField
Click +1 button 3 times (variable becomes 4)
Click New John Value Button. The new variable value is displayed in the 2nd numeric field.
I hope this helps
Views
Replies
Sign in to like this content
Total Likes