Using counter as part of form names

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";
  }