[thelist] JavaScript focus & getElementByID
.jeff
thelist at lists.evolt.org
Wed Jan 15 11:41:06 2003
martyn,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Martyn Haigh
>
> function getObj(name)
> {
> if (document.getElementById)
> {
> this.obj = document.getElementById(name);
> this.style = document.getElementById(name).style;
> }
> else if (document.all)
> {
> this.obj = document.all[name];
> this.style = document.all[name].style;
> }
> else if (document.layers)
> {
> this.obj = document.layers[name];
> this.style = document.layers[name];
> }
> }
>
> I have this input element
> <input type="checkbox" id="KnowMore" name="KnowMore"
> value="True" />
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
no offense, but you really should resist the urge to use the id to access
form elements. the elements array in combination with the name attribute
has much better support.
however, in cases where you're working with other tags, your method is quite
nice.
.jeff
http://evolt.org/
jeff at members.evolt.orghttp://members.evolt.org/jeff/