Question : javascript  varaible

for(var i=0; i < document.form.test.length;i++)

How would I make form a variable?? I have multiple forms in a page that are hidden and become visible based on clicking something. Since they all have different form names... how do feed the form name as a variable to a function??

Thanks

Answer : javascript  varaible

use : document.forms.length and document.forms[i]

test page :



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
<html><head></head><body>
<form name="form_1"></form>
<form name="form_2"></form>
<form name="form_3"></form>
<form name="form_4"></form>
<script language="javascript">
for(var i=0; i < document.forms.length;i++) {
   alert( document.forms[i].getAttribute("name") );
}
</script>
</body></html>
Random Solutions  
 
programming4us programming4us