[thelist] DOM: Counting text Inputs in a form?

Tom Dell'Aringa pixelmech at yahoo.com
Mon Mar 3 15:14:01 CST 2003


--- Frank <lists at frankmarion.com> wrote:
>
> Can anyone suggest a simple method to count text inputs in a form?
> I want to take the contents of each field and set them in an
> array. I haven't really figured out how to isolate them from the
> rest of the other form elements.

Use the DOM lvl 0 elements array. (not tested but should work)

var textInputs = 0;
var textArray = new Array();

for(i=0; i < YourForm.length; i++)
{
  if(YourForm.elements[i].type == "text")
  {
    textInputs += 1;
    textArray[i] = YourForm.elements[i].value;
  }
}

HTH

Tom


}

=====
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http://www.pixelmech.com/
var me = tom.pixelmech.webDeveloper();

http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



More information about the thelist mailing list