Programmatically fire onChange() event in Netscape

R

Robbie

Hi,

I want to programatically fire an event. I have it working in IE, but
Netscape won't work. What is the Netscape equivalent to, or a
workaround for:

document.myForm.myField.onchange();

I've read many posts, but none seem to answer my question. Anyway, my
example follows.

Thanks!


<HTML>
<HEAD>
<SCRIPT language=JavaScript>
// <!--
function MyFunction()
{
alert('MyFunction() fired');
// do something...
}

function onload()
{
alert('onload() fired');
------------>> document.myForm.mySelectList.onchange();
------------>> WHAT IS THE NETSCAPE EQUIVALENT TO THIS? This works in
IE.
}
// -->
</SCRIPT>
</HEAD>

<body onload="onload()">
<form name="myForm" method="post" action="http://www.myPage.com">
...
<select name="mySelectList" id="mySelectList"
onChange="MyFunction()">
<option>
<option value="A">blah blah blah</option>
<option value="B">blah blah blah</option>
</select>
...
</form>
</body>

</HTML>
 
M

Martin Honnen

Robbie wrote:

I want to programatically fire an event. I have it working in IE, but
Netscape won't work. What is the Netscape equivalent to, or a
workaround for:

document.myForm.myField.onchange();

That is correct and works in Netscape, the problem is elsewhere, see below.

<HTML>
<HEAD>
<SCRIPT language=JavaScript>
// <!--
function MyFunction()
{
alert('MyFunction() fired');
// do something...
}

function onload()

Change the name of that function something different to onload, for instance
function loadHandler ()
{
alert('onload() fired');
------------>> document.myForm.mySelectList.onchange();
------------>> WHAT IS THE NETSCAPE EQUIVALENT TO THIS? This works in
IE.
}
// -->
</SCRIPT>
</HEAD>

<body onload="onload()">

then call
<body onload="loadHandler();">
here and it will work.
 
R

Robbie

Martin Honnen said:
Robbie wrote:



That is correct and works in Netscape, the problem is elsewhere, see below.



Change the name of that function something different to onload, for instance
function loadHandler ()

then call
<body onload="loadHandler();">
here and it will work.


THANKS! THAT DID THE TRICK!!!
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top