...

View Full Version : Using counter as part of form names



midohioit
10-03-2010, 08:31 PM
I have 2 questons.


1) Is there a way for the loop counter to loop while less then [a php variable]?
2) Is there a way to use a counter in the name of the form elements? Example, instead of "switchBox1" use: "switchBoxCounter"
instead of "nameaddy1" use: "nameaddyCounter"


if(document.form1.switchBox1.checked)
{
document.form1.nameaddy1.style.backgroundColor = "#E5E5E5";
}
else
{
document.form1.nameaddy1.style.backgroundColor = "#FFFFFF";
}

Philip M
10-03-2010, 09:02 PM
1)

while (x < 10) {
or for (i = 10, i>=0; i--) {2) Use square bracket notation.


if (document["form1"]["switchBox"+counter].checked) {
NEW! FREE DELIVERY when you collect from store. - Debenhams' advertisement



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum