da**********@gm ail.com wrote:
I got the following error in a javascript I wrote. The script works
fine, but why is the error being displayed???
##### Here comes the little script:
function chgMusicLink(us erid,userlink,u sertype) {
var card_music_id = document.getEle mentsByName(use rid)[0].value;
document.getEle mentsByName(use rlink)[0].href="/card_music_prev iew.tcl?card_mu sic_id="+card_m usic_id+"&card_ music_type="+us ertype;
}
#####
Thanks
Does the error appear in IE but not Firefox?
If this is the case then it is because IE does not recognise the name
attributes in most tags, for example getElementsByNa me will return an
empty list when the only matching name attributes are in divs.
The explanation I plagiarised and the list of tags IE recognises is
here
http://jszen.blogspot.com/2004/07/whats-in-name.html
A possible drawback to relying on getElementsByNa me is that the name
attribute has been deprecated in XHTML1.0 and the w3c plan to remove
it altogether, they have already replaced the name attribute with id
for <a> and <map> in the current XHTML1.1 proposal.
A solution is to use a different attribute, (most likely id or
classname, would consider title if I get desperate), then use a
function that walks over the dom or a nodelist (if you use
getElementsByTa gname to reduce the number of nodes searched) to find a
match.
You could do this yourself but there are plenty of pre-written versions
that do this, unfortunately I can't remember where any are.
Hope this helps
Tim