- Mario Daniel Carugno wrote:
> > I tend to give even input fields an id attribute so that I can accessI've seen both used but to be consistent (when using YUI) its better to
> > them easily:
> > <input type="text" name="the_name" id="the_name"/>
> > document.getElementById('the_name').value = 'default value';
> > Or using YUI:
> > var the_name = YAHOO.util.Dom.get('the_name');
> > the_name.value = 'default value';
> Thank you !
> I've discovered the first method by myself.
> Is the YUI method better or recommended ?
use the YUI method. You could even create a reference to it by doing:
var YUD = YAHOO.util.Dom;
So you can then just use `YUD.get('the_name')` wherever in your code.
Just saves you typing more characters.