[thelist] javascript and IDs
Anthony Ettinger
apwebdesign at yahoo.com
Tue Oct 4 12:19:05 CDT 2005
--- Kasimir K <evolt at kasimir-k.fi> wrote:
> Anthony Ettinger scribeva in 2005-10-04 16:32:
> > Ok, so I have a <form id="foo">
> ...
>
> > 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">
>
> so how about:
>
> document.getElementById('foo').elements['foo'].name
> = 'bar';
Great thanks! This is closest to what I needed:
function changeAttrib(id, attrib, newValue)
{
var elemObj = document.getElementById(id);
elemObj.setAttribute(attrib, newValue);
return true;
}
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