tweetie
February 25, 2004, 7:39pm
1
I know I’m beeing pushy…
But i was wondering if we could use variables in the functions that deal with elements…
Suppose I have 5 stripes (stripe1 thru strip2) on a form, normally we would do:
elements.stripe1.visible=true;
elements.stripe2.visible=true;
elements.stripe3.visible=true;
elements.stripe4.visible=true;
elements.stripe5.visible=true;
It would be fun if we could use a variable for the elementname. We could use a loop defining the elementname…for example (hope i got the syntax right)
for ( var i = 1 ; i < 6 ; i++ )
{
var thingie=‘stripe’+i;
elements.thingie.visible=true;
}
Just brainstorming over here in Rotterdam
pbakker
February 26, 2004, 9:32am
2
You can build up a textstring like that and then evaluate it, using eval(…)
Paul
maarten
February 26, 2004, 10:17am
3
this will work:
elements.stripe1.visible=false;
elements.stripe2.visible=false;
elements.stripe3.visible=false;
for ( var i = 1 ; i <= 3 ; i++ )
{
var thingie=‘stripe’+i;
elements[thingie].visible=true;
application.sleep(1000)//wait 1 sec
}
tweetie
February 26, 2004, 10:31am
4
I’m gonna buy Javascript for Dummies right away
Thkx guys
I’m assuming the delay in the loop is to allow Servoy to catch up with the interface. Is the 1 second wait time arbitrary? Could one get by with say .10 second for each element? If you have a lot of elements on a form a 1 second wait time could get expensive.
maarten
February 26, 2004, 2:12pm
6
No, you can leave out the delay.
It’s just for seeing script at work.