"Michael Hill" <hi****@charter.net> wrote in message
news:vn************@corp.supernews.com...
If I have:
<a href="javascript:myfunct('cool_links')" id="cool_links">
<quote cite="http://jibbering.com/faq/#FAQ4_24">
I have <a href="javascript:somefunction()"> what ... ?
</quote>
and I refer to it as:
function myfunct(mylink)
{
document.getElementById[mylink]
<snip>
JavaScript uses square brackets in bracket notation property accessors,
for indexing arrays and to define array literals. Parentheses are used
for function calls. As you have it, this line of code is attempting to
read a property of the document.getElementById function. Because
JavaScript functions are objects this is feasible but the
document.getElementById function will not normally have a property with
a name that corresponds with the toString value of the myLink parameter
of the myfunct function.
Try:-
document.getElementById(mylink);
- instead. However, this function does not do anything with the result
of the function call so there is probably no point in calling the
function at all.
Note that getElementById retrieves references to DOM elements with the
corresponding ID attribute. Elements that only have NAME attributes must
be accessed by other means.
Richard.