If given 1 element in an array of textboxes... find which element number it is

Giganews Newsgroups
Subject: If given 1 element in an array of textboxes... find which element number it is
Posted by:  \"A_Michigan_User\ (Michigan_RE_M0…@ameritech.net)
Date: Thu, 15 Nov 2007

I call this Javascript function with "GetEleNum(this)"
passing it 1 of the elements of a text-box array.

Is there a QUICK way to get the "element #"?    I'm currently using this
SLOW code.
(It works... but I need something better/faster.)

function GetEleNum(c)
{
// Given 1 element in this textBox array... what is the array element #?

var i;

for(i=0; i<form1.txtBox.length; i++)
  if(form1.txtBox[i] == c) return i;

return 0;  // Not found
}

Thanks

Replies