Javascript Error only with MacOS 9 + IE 5

V

Ved Antani

Hi,

I have a strange problem. I have a script that runs perfectly well on
Win+IE5, but fails in Mac OS 9+IE5.

The following assignment is used in submitRequest() function :

var result= allForms["RESULT_FORM"][0];

This thing works fine in Win+IE5, but in MacOS9+IE 5 we get the
following JS error : allForms.RESULT_FORM.0 is not an object.

I can not understand why this thing is happening.

I would appreciate if you can give some guidance.

--Ved Antani
 
R

RobG

Ved said:
Hi,

I have a strange problem. I have a script that runs perfectly well on
Win+IE5, but fails in Mac OS 9+IE5.

The following assignment is used in submitRequest() function :

var result= allForms["RESULT_FORM"][0];

This thing works fine in Win+IE5, but in MacOS9+IE 5 we get the
following JS error : allForms.RESULT_FORM.0 is not an object.

We need to see a little more code. Can you show how you create
"allForms"? If you are using:

var allForms = document.forms;

Then allForms will be a collection of all the forms. If one of the
forms is called "RESULT_FORM", then:

var result = allForms["RESULT_FORM"][0]

will create a reference to the first element in the form. Following is
a trivial case that works in IE 5 on OS 9 and IE 5.2 on OS X:

<html><head>
<title>IE play</title>
<script type="text/javascript">
function sayForms() {
var allForms = document.forms;
var result = allForms["RESULT_FORM"][0];
alert(result.nodeName);
}
</script>

</head><body>
<form name="form1" action="">
<input type="text" value="in form 1">
</form>
<br>
<form name="RESULT_FORM" action="">
<input type="text" value="in RESULT_FORM">
<input type="button" value="click me" onclick="
sayForms();
">
</form>
</body></html>
 
R

RobG

RobG wrote:
[...]
var result = allForms["RESULT_FORM"][0]

will create a reference to the first element in the form. Following is
a trivial case that works in IE 5 on OS 9 and IE 5.2 on OS X:

Forgot to add that if you want the value of the element (presuming it
is a text input) then use:

var result = allForms["RESULT_FORM"][0].value;
 
V

Ved Antani

Hi Rob, Thanks a lot for your help.
The major code is like this

In the HTML file I have the following JS Functions
--------------------------------------------------
/* Initializes the 'allForms' arry */
function initialize(doc)
{
top.initDocument(doc);
}

function submitForm(){
top.submitRequest("aaa",
url,
action,
func,
"",
new Array(""),
"_top");

}
....
/* Later I have the following Form in the same HTML */
/* The Hidden input are null and haveing name as null too will this
create any problems ? */

<form name="RESULT_FORM" method=POST>
<input type="hidden" name="" value="">
<input type="hidden" name="" value="">
<input type="hidden" name="" value="">
<input type="hidden" name="" value="">
<input type="hidden" name="" value="">
</form>
---------------------------------------------------------------------
The function 'initDocument()' creates the allForms array of forms and
the 'submitRequest()' method submits the record. While submitting the
form, we get the error in IE5+MacOS 9
---------------------------------------------------------------------
Code of submitRequest() is something like :
---------------------------------------------------------------------
function submitRequest( url, //Url to submit to
generalData, //Some other data
formNames, //Forms to be submitted
target,
method) // request method for form.
{

//We get the form here

var result= allForms["POR_RESULT_FORM"][0];

result.action= url;
result.target= target;
result.method= ((method=="GET" || target=="por_main") ? "GET" : "POST");
//we populate all the elements of the forms to be submitted to
//'result' object and then submit it
//Probably the point of error
result.submit();
}
---------------------------------------------------------------------
I think the problem is with the syntax of the last time 'result.submit();'
This works well in IE 5+ Win and fails saying
'RESULT_FORM.0 is not an object'


Please help.

--Ved



RobG wrote:
[...]
var result = allForms["RESULT_FORM"][0]

will create a reference to the first element in the form. Following is
a trivial case that works in IE 5 on OS 9 and IE 5.2 on OS X:


Forgot to add that if you want the value of the element (presuming it
is a text input) then use:

var result = allForms["RESULT_FORM"][0].value;
 
V

Ved Antani

RobG said:
Ved said:
Hi,

I have a strange problem. I have a script that runs perfectly well on
Win+IE5, but fails in Mac OS 9+IE5.

The following assignment is used in submitRequest() function :

var result= allForms["RESULT_FORM"][0];

This thing works fine in Win+IE5, but in MacOS9+IE 5 we get the
following JS error : allForms.RESULT_FORM.0 is not an object.


We need to see a little more code. Can you show how you create
"allForms"? If you are using:

var allForms = document.forms;

Then allForms will be a collection of all the forms. If one of the
forms is called "RESULT_FORM", then:

var result = allForms["RESULT_FORM"][0]

will create a reference to the first element in the form. Following is
a trivial case that works in IE 5 on OS 9 and IE 5.2 on OS X:

<html><head>
<title>IE play</title>
<script type="text/javascript">
function sayForms() {
var allForms = document.forms;
var result = allForms["RESULT_FORM"][0];
alert(result.nodeName);
}
</script>

</head><body>
<form name="form1" action="">
<input type="text" value="in form 1">
</form>
<br>
<form name="RESULT_FORM" action="">
<input type="text" value="in RESULT_FORM">
<input type="button" value="click me" onclick="
sayForms();
">
</form>
</body></html>
Small Correction in the line var result = allForms["POR_RESULT_FORM"][0]
is actually var result = allForms["RESULT_FORM"][0]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,627
Members
45,328
Latest member
66Teonna9

Latest Threads

Top