JavaScript For Loop

Like this blog? Consider exploring one of our sponsored banner ads...

Here is an example of the JavaScript for loop (which is identical to the PHP for loop). Again I used Prototype. This basic example illustrates hiding multiple divs. So for example if you dynamically generate a page with divs you can show or hide them with an onchange() function call to something like this.

if ($F('validationid').toString() == '18'){
   for (i=0; i<=10; i++){ Element.show('subsetList'+i); }
}

About this entry