473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Mozilla/Netscape - don't understand error

Hi,

I'm getting the fololowing error in Mozilla and Netscape, which does not
occur in IE.

'form1 is not defined' at line 195

line 195 is the third line below:

function UpdateTagValues()
{
for (iIndex=0; iIndex<=form1.cboValue.length+1; iIndex++)
{
form1.cboValue.options[0] = null;
}
for (iIndex=0; iIndex<=iTagID.length; iIndex++)
{
if (iTagTypeID[iIndex] == form1.cboType.value)
{
var option = new Option(sTagValue[iIndex], iTagID[iIndex]);
form1.cboValue.options[form1.cboValue.length] = option;
}
}
}and the data refered to is (part):var iTagID = new Array();
var iTagTypeID = new Array();
var sTagValue = new Array();

iTagID[0] = 7;
iTagTypeID[0] = 3;
sTagValue[0] = 'Christmas Card';
iTagID[1] = 8;
iTagTypeID[1] = 3;
sTagValue[1] = 'Test - can be deleted';
iTagID[2] = 9;
iTagTypeID[2] = 5;
sTagValue[2] = 'Chief Executives/Directors';form1 is defined:<form
name="form1" id="form1" method="post" action="">etc...and finally, the
calling element is:<select name="cboType" id="cboType"
onchange="UpdateTagValues();">etc...Any advice appreciated.regards,NEIL
Sep 28 '06 #1
2 1170


Neil wrote:
'form1 is not defined' at line 195
for (iIndex=0; iIndex<=form1.cboValue.length+1; iIndex++)
<form
name="form1" id="form1" method="post" action="">
Use
document.forms.form1
instead of
form1

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 28 '06 #2
Neil wrote:
Hi,

I'm getting the fololowing error in Mozilla and Netscape, which does not
occur in IE.

'form1 is not defined' at line 195

line 195 is the third line below:

function UpdateTagValues()
{
for (iIndex=0; iIndex<=form1.cboValue.length+1; iIndex++)
iIndex should be kept local, especially if being used as a counter:

for (var iIndex=0; ... )
{
form1.cboValue.options[0] = null;
Here you appear to be using the name of the form as a global variable.
That is an IE-ism that is not supported by most other browsers, use:

document.form1.cboValue.options[0] = null;

or the more strict:

document.forms['form1'].elements['cboValue'].options[0] = null;

Though if the intention is to remove all the options, then just set the
length of the select to zero (0) with no loop:

document.forms['form1'].elements['cboValue'].length = 0;

}
for (iIndex=0; iIndex<=iTagID.length; iIndex++)
{
if (iTagTypeID[iIndex] == form1.cboType.value)
{
var option = new Option(sTagValue[iIndex], iTagID[iIndex]);
form1.cboValue.options[form1.cboValue.length] = option;
}
}
}and the data refered to is (part):var iTagID = new Array();
var iTagTypeID = new Array();
var sTagValue = new Array();

iTagID[0] = 7;
The intention here appears to be to set the ID value as '7'. For valid
HTML, the ID attribute value can't start with a digit, though it can
contain digits elsewhere.

iTagTypeID[0] = 3;
sTagValue[0] = 'Christmas Card';
iTagID[1] = 8;
iTagTypeID[1] = 3;
sTagValue[1] = 'Test - can be deleted';
iTagID[2] = 9;
iTagTypeID[2] = 5;
sTagValue[2] = 'Chief Executives/Directors';
You might find it easier to initialise these arrays (given that the ID
value may need to be modified) using:

iTagID = [7, 8, 9];
sTagValue = ['Christmas Card', 'Test - can be deleted, 'Chief
Executives/Directors'];
iTagTypeID = [3, 3, 5];

[...]
form1 is defined:<form
name="form1" id="form1" method="post" action="">etc...

--
Rob

Sep 28 '06 #3

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

Similar topics

1
by: Sims | last post by:
Hi, if i use... // php $info = getenv("HTTP_USER_AGENT"); // I noticed that Mozzila and Netscape <6(?) both use the same Agent. // so i was thinking of if...
15
by: Peter Bremer | last post by:
Hi all, I've written this little piece of code, which doesn't seem to work in Mozilla 1.5. I haven't tried it on other Gecko browsers, but I've found some indication that Netscape 6+ has the...
6
by: Daniel | last post by:
I have this script and I want to adapt it to the DOM of most / all well known browsers like mozilla and netscape.. at the moment it only works in ie4+ en ns6. can anybody give me some hints ?!?...
6
by: Lucien | last post by:
I have trouble using JavaScript to access an embedded real audio in netscape navigator 7.1 and mozilla 1.4 and 1.5 (It seems to work in NS 4.7) Eg. <EMBED NAME=javademo SRC="test.rpm"...
5
by: Roman Blöth | last post by:
Hello out there, pls excuse if my xposting might fall into a false group - this is a quick problem which I should solve soon... Why the heck would Mozilla 1.2.1 on a Mac (OS 9.x) render a...
30
by: Matt Probert | last post by:
Is it just me (probably) or is Mozilla and the newer Firefox full of CSS rendering bugs? I ask, because some strange effects occur with Mozilla and Firefox which don't happen in Opera and dare I...
3
by: kj | last post by:
This problem is driving me nuts. The code at the end of this post below works fine with IE, but fails with Mozilla. You can see it in action at http://tinyurl.com/2jvo3 With Mozilla 1.4 and...
6
by: hsomob1999 | last post by:
so i have a <ul> and I allow the user to append items to it. The problem is that on mozilla the <span class="line"> which is just a line to divide the sections gets overlaped and doesnt move down...
10
by: News | last post by:
I have a page up trying to learn how to ID a browser and other info. http://wyght.com/warren/testPos.html here is the code <script type = "text/javascript"> var space = ", "; var name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.