In article <cd**************************@posting.google.com >,
js******@hotmail.com enlightened us with...
I have a page with many, dynamically generated combo boxes
You mean select elements?
Combo boxes are VB and allow both a selection and text input.
and I want
to check all of them, before I add a unique value to specific combo.
What would be the best way to work through the document and without
needing to know the name of each combo box, check its value?
Please explain what you mean by "check its value".
Select elements have options. They also have a selectedIndex property to tell
which option has been chosen. The options have values.
Do you want to check what options (option values) are in each select, which
option has been chosen for a select...?
To iterate through a form, named "form1":
var L = document.forms["form1"].elements.length;
for (var i=0; i<L; i++)
{
/* 'e' will be a form element; do whatever with it */
var e = document.forms["form1"].elements[i];
}
'e' will have a type, name, and all other attributes associated with a form
element.
Example:
alert(e.name);
alert(e.type);
I'm assuming the elements are in a form. The above is more cross-browser than
using getElementsByTagName, but I think it's also slower. Using
getElementsByTagName, however, will allow you to get all the select elements
across ALL forms in a page if you have multiple forms, not just one. There's
pros and cons to each choice.
And don't forget - not everyone has javascript enabled or even available.
HTH
--
--
~kaeli~
A man needs a mistress... just to break the monogamy.
http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace