[Javascript] How to refer to an HTML element's ID attribute

Robert Pollard rpollard at apple.com
Sun Nov 16 13:16:50 CST 2003


Very good suggestion.  Thanks for all your time.

Robert

On Friday, November 14, 2003, at 09:42 PM, David Lovering wrote:

> Perhaps you should write a routine like "getObject(nameOrID)" which 
> tests
> for the existence of the object via getElementById, and if this is
> undefined, try getting it by name.  If either is defined and exists, 
> return
> the object handle to it, or return null (-1) if it isn't.
>
> At least that is one way of encapsulating a solution that will work on 
> a lot
> of different platforms/versions.  Any additional "tweaks" that are 
> necessary
> to handle oddball browsers can then be put in one place -- getObject --
> without requiring massive rewrites of all your subsidiary code.
>
> -- Dave Lovering
>
>
> ----- Original Message -----
> From: "Robert Pollard" <rpollard at apple.com>
> To: "[JavaScript List]" <javascript at LaTech.edu>
> Sent: Friday, November 14, 2003 10:00 AM
> Subject: Re: [Javascript] How to refer to an HTML element's ID 
> attribute
>
>
>> I apologize for being vague but I thought I would get a greater 
>> variety
>> of responses since I was looking for several different answers.
>>
>> What I needed was to get the value of an element by referring to its'
>> ID attribute.  What I wound up doing was using something like
>> document.getElementById("FeePercent").value.  I later found out this
>> wasn't compatible with all browsers (Netscape 4.7) that we are using.
>>
>> The question I have is what is the most compatible way of referring to
>> the HTML ID attribute?  Is there a way to refer to the element with 
>> the
>> ID of "FeePercent" in without using the DOM function?
>>
>> Thanks for everyones response.  They have been quite helpful.
>>
>> -- Robert Pollard
>>
>> On Thursday, November 13, 2003, at 03:59 PM, Robert Pollard wrote:
>>
>>> Hello all,
>>>
>>> What is the syntax to refer to an HTML element's ID attribute?
>>>
>>> Thanks,
>>>
>>> Robert Pollard
>>>
>>> _______________________________________________
>>> Javascript mailing list
>>> Javascript at LaTech.edu
>>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>>
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list