www.webdeveloper.com
Results 1 to 2 of 2

Thread: Using counter as part of form names

  1. #1
    Join Date
    Oct 2010
    Posts
    5

    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"


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

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    1
    Code:
    var limit=Number(<?echo $phpVar; ?>);
    for(var i=0;i<limit;i++){
    // whichever
    }
    2
    Code:
    var el=document.forms['form1'].elements['switchBox'+counter];

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles