#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    136
    Rep Power
    14

    Question Tabbing between form fields in javascript


    I'd like to tab my form fields, in a loop, using:

    function tabbing(field1, field2,field3,field4)
    { for (i=0;i<argumrntsNumber;i++)
    {
    document.form1[fieldName].tabIndex=i;
    }
    }

    I'd like "argumentsNumber" to hold the number of arguments
    that the function gets (field1, field2,field3), which can be changed of course,
    so the loop will work for eavh field, until all list is tabbed.
    ("i" is teh number of the tabIndex).
    I need it for IE and ns6.
    Thanks for any help.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    all arguments go into the arguments[] array - regardless of whether named arguments are used / no matter how many arguments are provided...

    try this (haven't tested)
    Code:
    function tabbing() 
     {for (var i=0;i<arguments.length;i++) 
       {document.forms.form1.elements[arguments[i]].tabIndex=i;} 
     }
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    136
    Rep Power
    14
    Thanks. Finally I used the following, which is like what u said, except for the "forms" and "elements" which I guess r optional (?). Also for the tabIndex, needed i+1;


    function tabbing(field1,field2,field3)
    {var fieldName;
    for (i=0;i<arguments.length;i++)
    {fieldName=arguments[i];
    document.form1[fieldName].tabIndex=i+1;
    }
    }

    Thanks much for making effort.

IMN logo majestic logo threadwatch logo seochat tools logo