PDA

Click to See Complete Forum and Search --> : [java script] different browsers


DaveR
Nov 19th, 2004, 06:10 AM
Hi,

I have the following code on an asp page and it works fine from a mozilla bowser but when run from internet explorer is doesnt seem to work at all.

function Approach (theform) {
var pregen = 0 ;
pregen = theform.sel_app_1.value
alert(pregen)
return;
}

called from a select box as follows.
onChange= "Approach(this.form) ;"

With the mozilla browser it displays the selected value

With internet explorer it just displays the default value of 0

If any one has even the slightest idea of what the problem is here , please let me know.

Thank

mendhak
Nov 19th, 2004, 06:14 AM
How are you getting that to run without semicolons in place?

DaveR
Nov 19th, 2004, 06:38 AM
There are semi colons on the code on the page, deleted them by accident on the post.

plenderj
Nov 19th, 2004, 06:55 AM
I've never used the this keyword in js before... I'd normally just use document.myform or something to that effect...

DaveR
Nov 19th, 2004, 07:50 AM
Even when I use the the actual form name in the function , ie. in effect ignoring the input parameter, it still gives me a value of 0 .

Acidic
Nov 19th, 2004, 08:05 AM
Why not:<textarea onchange="Approach(this)"></textarea>
...
function Approach (_obj) {
var pregen = 0 ;
pregen = _obj.value
alert(pregen)
return;
}

DaveR
Nov 19th, 2004, 10:46 AM
I am calling it from a drop down select box, eventually I want the function to do calculations on a few different drop down boxes on the form.

Functions calls ok ,but it just cant read the selected value of the dropdown box.

Acidic
Nov 19th, 2004, 10:50 AM
<select onchange="Approach(this.value)">
<option value="abc">abc</option>
...
</select>

DaveR
Nov 19th, 2004, 11:13 AM
Its in the function the problem is:

function Approach (theform) {
var pregen = 0 ;
pregen = theform.sel_app_1.value; alert(pregen);
return;
}

theform.sel_app_1.value gives me a value of 0 no matter what I select.
Works fine in mozilla.

Jop
Nov 20th, 2004, 08:49 AM
It's a faulty implementation on IE's side:

http://www.shaftek.org/blog/archives/000153.html

CornedBee
Nov 20th, 2004, 09:05 AM
A good reason always to use the value attribute.