473,695 Members | 1,685 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 3483


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
3830
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
5679
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
4932
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
8623
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
8565
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
9113
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
8822
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...
1
6488
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
5837
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();...
1
2997
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
2269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1971
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.