[thelist] javascript and IDs

Anthony Ettinger apwebdesign at yahoo.com
Tue Oct 4 11:32:55 CDT 2005


Ok, so I have a <form id="foo">

Is this the best way to access descendents of <form>?
By keying off the ancestor, and then looping through
it's elements?

Or should I give each form element it's own id...

I want to change the value of an attribute of an input
field:

<input type="text" name="foo">

want to change it to 

<input type="text" name="bar">


What I ended up doing was giving the <input> element
an id="searchfield", and then looping through it's
attributes using '.attributes' on the input object,
and testing the name of the attribute == 'name'. and
then replacing it's value with 'bar'.

Is there an easier way to access an attribute of an
element if I know it's direct path?

Seems to me very inefficient to have to do looping if
it's not necessary.

Anthony Ettinger
ph: (408) 656-2473
blog: http://www.chovy.com


		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


More information about the thelist mailing list