Javascript for loop involving fieldname[i]'s
Posted: Wed Nov 22, 2006 6:27 am
I am buildign a form validation script which will loop through certain fieldnames. These fieldnames are the same apart from they are numbered i.e.
tenanttype1
tenanttype2
tenanttype3
Where in php we can do something like:
I am looking to find out what the correct punctuation as it were in jscript that would perform the same concept, allowing me to insert the variable 'count'. So I have the following as an example:
Any help appreciated,
Thanks, Will
tenanttype1
tenanttype2
tenanttype3
Where in php we can do something like:
Code: Select all
echo "if (document.form1.tenanttype".$count.".value == 'students'";Code: Select all
var count = 1
var p = 10
for (i=0;i<=p;i++) {
if (document.form1.tenanttype[count].value == 'professional' || document.form1.tenanttype[n].value == 'students') {
document.getElementById('contsum1').value = '';
document.getElementById('contsumrow1').style.display = '';
count++;
}Thanks, Will