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???????? ???

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.