[thelist] Newbie DOM question

Aaron Cole aaroncole at gmail.com
Wed Aug 16 17:09:43 CDT 2006

I've been trying to figure this one out all day.  Now I'm ready to swallow
my pride. :)

I'm looking to set the value="" of any input elements with an
attribute/value pair of  type="text" to "foo".

Here's what I've got:

var inputs = document.getElementsByTagName("input");
var inputType = inputs[i].getAttribute("type");

             for (var i=0; i< inputs.length; i++) {
                 if (inputType[i].nodeValue = "text") {
                    inputs[i].setAttribute("value", "foo");

With this script, the value of every input on my page is being set to
"foo".  The conditional seems to be the problem, but I can't figure out why.

Any idea?


More information about the thelist mailing list