gregs

IE , the dom and long numbers

by gregs on Apr.27, 2007, under JavaScript

I just spent the best part of 45 minutes trying to figure out a weird issue with a value I was pulling out of a select box (using $F(element)). The value in question was a long number: 1000002229651626, which IE converted at the time of writing the value to the page (this was an AJAX call) to: 1.00000222965163e+15.

IE decided to convert my number when I was using the new Option() method to populate the drop down, making the debug process even harder. I personally can't wait until we get a firebug like extension for IE, right now I'd just settle for an option to view the rendered source.

Rant over, the solution is to convert the number to a string:

JavaScript:
  1. selectBox[x] = new Option('Some text',new String(1000002229651626),false);

On the plus side I came across a neat way to debug values in a form field using the address the browser address bar:

CODE:
  1. javascript:alert(document.all.myfield.value); void(0)

And to see what IE had actually written to the page:

CODE:
  1. javascript:alert(document.all.myfield.innerHTML ); void(0)


2 Comments for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!