Jump to content

[SOLVED] IE giving error whereas Firefox does not


stockton

Recommended Posts

Please tell me why IE6 is having an issue with the following Javascript

                var MyIssuedValue = document.getElementById("IssuedValue");

                var MyOutstandingValue = document.getElementById("OutstandingValue");

                IssuedValue = parseInt(MyIssuedValue,10);

                alert("IssuedValue = "+IssuedValue);

IE tells me Problem with this Web page

Line: 154

Char: 17

Error: Object does not support this property or method

Code: 0

Now there is no line 154 in the html page so I am looking at the attached/called Javascript and line 154 is the alert("IssuedValue = "+IssuedValue); line???????? ???

parseInt()'s 1st param is "The string to be parsed"

 

My guess is when you do:

var MyIssuedValue = document.getElementById("IssuedValue");

...

var IssuedValue = parseInt(MyIssuedValue,10);

 

MyIssuedValue is the element/OBJECT, when you want the string text in it.

document.getElementById("IssuedValue").value might work if its a textfield

OR if its just text inside a span or div...

document.getElementById("IssuedValue").innerHTML (gets the html inside of element) orrrr...

document.getElementById("IssuedValue").firstChild.nodeValue (gets the textNode, then the value of it is the text itself)

 

Ari

 

can you post really simple html example u can post?

 

like just the span or form field that has the number in it

and an onclick on a button which runs yer code and alerts you?

 

I can check it out with FireFox/Firebug(FF add-on) and see where problem lies better.

Thank you for your suggestions and offer of help but the problem was that I was not defining a var.

Now why Firefox accepts this and IE does not beats me.

I altered

IssuedValue = parseInt(MyIssuedValue,10);

to

var IssuedValue = parseInt(MyIssuedValue,10);

& now it works.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.