473,626 Members | 3,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error: document.getEle mentsByName(use rid)[0] has no properties

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

May 8 '06 #1
4 7965
alert(document. getElementsByNa me(userid)).

Check if you really got an object. I guess not.

May 8 '06 #2
da**********@gm ail.com said the following on 5/8/2006 5:44 AM:
I got the following error in a javascript I wrote. The script works
fine, but why is the error being displayed???


Evidently it doesn't "work fine" or you wouldn't get the error.
You get the error because there is an error in your code.

What is the error message?

Your problem probably lies in the area of you passing the function a
string parameter to try to access an object that doesn't exist.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 8 '06 #3
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

May 8 '06 #4
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???
Because the code is junk^W error-prone.
##### 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; }

#####


<URL:http://pointedears.de/scripts/test/whatami#inferen ce>
<URL:http://rfc-editor.org/rfc/rfc3986.txt>
PointedEars
--
When the power of love overcomes the love
of power, the world will know peace.
-- Jimi Hendrix
May 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1884
by: CJ | last post by:
Hi In my PHP script I'm able to update bookmarks without in hassles but document properties just don't work! I know in VB custom properties can be changed with the following: wdApp.ActiveDocument.CustomDocumentProperties(MyProperty) = "NewValue"
3
1826
by: StrongBad | last post by:
Does anyone know of a way to access the document properties of an office document using ASP? I need to be able to read things like the Title, Author, and Comments fields and pull that information into a web page. Any help is greatly appreciated. Thanks!! Eric
1
2140
by: Patrick Conway | last post by:
Hi! I'm building a Windows form that allows users to view a list of files (and their properties(metadata)) stored in a certain directory. All of the files in the directory are a result of a mail merge created in another process. In the Merge process, I used "BuiltInDocumentProperties"
4
5369
by: Craig | last post by:
I'm trying to build a filter for a file search where the search will be able to filter out certain files according to certain "file properties", like Owner, Creation Date, etc. MS does this in some Open dialogs, within the dialog, you can click on Tools->Search->Advanced and search for files with specified file properties. Any ideas on how this is done in C#?
0
939
by: clintonG | last post by:
Does somebody have code or documented methodology that will audit controls in the framework to generate the names and values for the properties each control uses? <%= Clinton Gallagher METROmilwaukee (sm) "A Regional Information Service" NET csgallagher AT metromilwaukee.com URL http://metromilwaukee.com/ URL http://clintongallagher.metromilwaukee.com/
0
1449
by: Alan T | last post by:
I have modified custom properties of a Word document by code. And there are fields in this Word document link to the properties, however, after running the application and reopen the document, the field values are still the old value until I right click the field and select 'Update field', then the new value will populate the field.
4
1281
by: Morgan | last post by:
Hello! I'm trying to find out if it's possible to access the properties of an document uploaded via the fileupload control? The end goal is to dynamically insert the number of pages in a document into a database field when the file is uploaded, along with the filename and mime property. TIA! -- Morgan Web Developer
0
1119
by: Support | last post by:
Hello: Apparently we can read and write to Document Properties using Dsofile.dll (seel http://support.microsoft.com/?id=224351) My question is: can this be extended to non-native Microsoft files. For example, tiff files. And if so, what should I look for in VB.NET to read and write to those fileds
0
1393
by: hannahhhh1056 | last post by:
Hello! I´m trying to create a makro that finds the text in a wddocument formatted as "heading 1" and then puts it in the document properties. I know how to get the text into doc properties but i see more problems when i try to find the text formatted as heading. As you see below i will have the headingtext as a string and just put in document properties! Any suggestions? Please. Sub SelectField() Dim str As String ...
0
8262
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.