473,698 Members | 2,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

yet another 'object has no properties' error

I have a function that receives a form name and field name.

someFunc(formNa me, fieldName) {
var fieldVal = document.forms[formName].elements[fieldName].value;
[snip]
}

This triggers the 'has no properties error. An alert message shows the
correct values are being passed in. If I hardcode
var fieldVal = document.realFo rmName.realFiel dName.value;
no error is generated and fieldVal has the value of the input field.

An alert(document. forms.length) displays 1, which is what I would
expect. It seems if I try to access some part of the document through
variables in javascript errors are generated. If I hard code document
object names in the javascript then the javascript functions as
expected.

The generated document passes the w3c validator test, although that
doesn't look at all of the sourced javascript files; and the Mozilla
JavaScript console shows no errors until the above function is called.

How can I troubleshoot this problem?

Thanks

Dennis

Sep 28 '06 #1
3 3484


dr******@comcas t.net wrote:
I have a function that receives a form name and field name.

someFunc(formNa me, fieldName) {
var fieldVal = document.forms[formName].elements[fieldName].value;
[snip]
}

This triggers the 'has no properties error.
The generated document passes the w3c validator test, although that
doesn't look at all of the sourced javascript files; and the Mozilla
JavaScript console shows no errors until the above function is called.
Show us the function call so that we know the actual parameter values,
then show us the corresponding HTML markup for the form and the element.
Or post a URL where the problem occurs. Does the problem only occur
with Mozilla or other browsers too?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 28 '06 #2

Martin Honnen wrote:
dr******@comcas t.net wrote:
I have a function that receives a form name and field name.

someFunc(formNa me, fieldName) {
var fieldVal = document.forms[formName].elements[fieldName].value;
[snip]
}

This triggers the 'has no properties error.
The generated document passes the w3c validator test, although that
doesn't look at all of the sourced javascript files; and the Mozilla
JavaScript console shows no errors until the above function is called.

Show us the function call so that we know the actual parameter values,
then show us the corresponding HTML markup for the form and the element.
Or post a URL where the problem occurs. Does the problem only occur
with Mozilla or other browsers too?
The HTML markup with the function call:
<a href="javascrip t:getEmail('off iceInfo', 'officeEmail')"
title="Click here to select email addresses...">e Mail</a>
<input type="text" name="officeEma il" value="$officeE mail"
tabindex="9">

The javascript function:
function getEmail(formNa me, fieldName) {
var email =
window.document .forms[formName].elements[fieldName].value;
if (email.length 0) {
email += ",";
}
var link = "/cgi-bin/ldapEmailPickLi st.pl?formName= " + formName +
"&fieldName =" + fieldName;
link += "&emailList =" + email;
window.open(lin k, "", "menubar, scrollbars, resizable, width=650,
height=600");
return;
}

Sep 29 '06 #3

droes...@comcas t.net wrote:
Martin Honnen wrote:
dr******@comcas t.net wrote:
I have a function that receives a form name and field name.
>
someFunc(formNa me, fieldName) {
var fieldVal = document.forms[formName].elements[fieldName].value;
[snip]
}
>
This triggers the 'has no properties error.
The generated document passes the w3c validator test, although that
doesn't look at all of the sourced javascript files; and the Mozilla
JavaScript console shows no errors until the above function is called.
Show us the function call so that we know the actual parameter values,
then show us the corresponding HTML markup for the form and the element.
Or post a URL where the problem occurs. Does the problem only occur
with Mozilla or other browsers too?

The HTML markup with the function call:
<a href="javascrip t:getEmail('off iceInfo', 'officeEmail')"
title="Click here to select email addresses...">e Mail</a>
<input type="text" name="officeEma il" value="$officeE mail"
tabindex="9">

The javascript function:
function getEmail(formNa me, fieldName) {
var email =
window.document .forms[formName].elements[fieldName].value;
if (email.length 0) {
email += ",";
}
var link = "/cgi-bin/ldapEmailPickLi st.pl?formName= " + formName +
"&fieldName =" + fieldName;
link += "&emailList =" + email;
window.open(lin k, "", "menubar, scrollbars, resizable, width=650,
height=600");
return;
}
Meant to add that it occurs in both Mozilla and IE.

Sep 29 '06 #4

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

Similar topics

15
6745
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use javascript or vbscript it works. I will appreciate any help. I do the following (C#):
11
3831
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you experts. I would like to produce Javascript classes that can be "subclassed" with certain behaviors defined at subclass time. There are plenty of ways to do this through prototyping and other techniques, but these behaviors need to be static and...
26
5680
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized several parts of the DOM, but this does not include the window object. Thank you
2
4933
by: Moses | last post by:
Hi All, Is is possible to catch the error of an undefined element while creating an object for it. Consider we are not having an element with id indicator but we are trying to make the object for it indicator = document.getElementById('indicator');
8
4195
by: Kevin Blount | last post by:
I'm tyring to access an object created by using a method from a third party API. The documentation tells me what object should be return, and the properties of that object, but when I try and access one of those properties I've shown an error message saying that the Object doesn't support this property or method. Here's the code I'm using (edited to protect the third party NDA) 1: <% 2: dim siteApi, userApi
0
8680
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
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
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...
0
5861
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
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.