Set the tab index

[Total: 0    Average: 0/5]

You can set the order which the tab key will send you through a form.

Head Code:

<script>
function check(id)
{
  var _obj=document.getElementById(id).attributes;
  for(var j=0;j<_obj.length;j++)
  {
    if(_obj[j].nodeName=="tabindex")
    var _str="ID of "+id+" has a tabindex of "+_obj[j].nodeValue;
    document.getElementById(id).value=_str;
    //alert(_str); /* if you want an alert uncomment */
  }
}
</script>

Body Code:

<form name=f1>
<input size=40 id=tb1 type="text" name="tb1" tabindex="1"><input type=button onclick="check('tb1')"><BR>
<input size=40 id=tb2 type="text" name="tb2" tabindex="-1"><input type=button onclick="check('tb2')"><BR>
<input size=40 id=tb3 type="text" name="tb3" tabindex="5"><input type=button onclick="check('tb3')"><BR>
<input size=40 id=tb4 type="text" name="tb4" tabindex="4"><input type=button onclick="check('tb4')"><BR>
<input size=40 id=tb5 type="text" name="tb5" tabindex="3"><input type=button onclick="check('tb5')"><BR>
<input size=40 id=tb6 type="text" name="tb6" tabindex="2"><input type=button onclick="check('tb6')"><BR>
</form>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *