Help creating loop

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
mbrother
New php-forum User
New php-forum User
Posts: 45
Joined: Thu Sep 15, 2011 1:09 pm

Tue Dec 27, 2011 10:43 am

Change all <input> tags to include an ID attribute as follows:
<input type="checkbox" onclick="codename()" name="check11" id="check11" size="10">

Code: Select all

function codename()
{
   var anEl1, anEl2;
   var x;

   for (x=1; x < 6; ++x)
   {
      anEl1 = document.getElementById('check1' + x);
      anEl2 = document.getElementById('check2' + x);

      if (anEl1.checked)
        anEl2.disabled = true;
      else
        anEl2.disabled = false;

      if (anEl2.checked)
       anEl1.disabled = true;
      else
       anEl1.disabled = false;
   }
}

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest