how to get this script to work in mozilla

J

Jon

Hi all

I got this javascript/function i works fine in IE but not in firefox
Do'es anyone know why?

// When I load the page
<script for="window" event="onload()" language=javascript>
laddainrulltyp()
</script>

//The event
<select name="cborulltyp" size="1" onChange="laddainrulltyp()">


//The function
<script language=Javascript>
function laddainrulltyp()
{
formen.txtrulltyp.value =
formen.cborulltyp.options(formen.cborulltyp.selectedIndex).text;
formen.txtrulltypid.value =
formen.cborulltyp.options(formen.cborulltyp.selectedIndex).value;
}
</script>

--

Mvh
Jon

(e-mail address removed)
 
M

Martin Honnen

Jon said:
I got this javascript/function i works fine in IE but not in firefox
Do'es anyone know why?

// When I load the page
<script for="window" event="onload()" language=javascript>
laddainrulltyp()
</script>

<script type="text/javascript">
window.onload = function (evt) {
laddainrulltyp();
</script>
works with both IE and Mozilla and other browsers.
The whole <script for="..." event="..."> is not at all or not well
supported in browsers other than MSIE.
 
J

Jon

Hi Martin

Your load function works fine, thanks.

But the function that write into the textboxes(txtrulltyp,txtrulltypid)
does'nt work.
Got any idea what I'am doing wrong.

//This function
<script language=Javascript>
function laddainrulltyp()
{
formen.txtrulltyp.value
=formen.cborulltyp.options(formen.cborulltyp.selectedIndex).text;
formen.txtrulltypid.value
=formen.cborulltyp.options(formen.cborulltyp.selectedIndex).value;
}
</script>
 
M

Martin Honnen

Jon said:
<script language=Javascript>
function laddainrulltyp()
{
formen.txtrulltyp.value

If you want to address the element
<select name="selectName">
inside of the form
<form name="formName">
in a cross-browser way then use
var select= document.forms.formName.elements.selectName;
 
R

RobG

Martin said:
Jon wrote: [...]
If you want to address the element
<select name="selectName">
inside of the form
<form name="formName">
in a cross-browser way then use
var select= document.forms.formName.elements.selectName;

Or you can use:

document.forms['formName'].elements['selectName']

which allows a little more freedom in the names used. If you use
<form name="my.form" ...> you can't get a reference to it using

document.forms.my.form

but you can get at it using:

document.forms['my.form']

Similarly for other special characters that are tolerated in names but
may confuse access methods such as ":", "[]", etc.
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top