views:

621

answers:

2

I have an dropdown with the following in it:

<select id="shipping" name="shipping_option">
<option SELECTED value="60">R60</option>
<option value="90">R90</option>  
<option value="100">R100</option>         
</select>

Then, when the content of the dropdown is changed, javascript runs updateTotal(), which is the following:

function updateTotal() {
      total = parseInt($("#shipping").val());
     }

Now that works fine in Firefox and Safari, but not in IE. It just doesn't work. It says object doesn't support function.

Is this a bug in IE, or a bug in jQuery relating to IE? As I said, this works perfectly, just not in IE.

+1  A: 

Some possible problems -- are you sure the <select> with the id shipping has loaded and has not been removed from the DOM? Is there another element with the id shipping? Is the value really a number? Also, the total variable, are you certain it was initialized with var to make it accessible where you're using it?

One note, it's a good idea to use parseInt() with the second parameter, so parseInt(foo, 10); to make sure it's parsed as a decimal number.

Try checking your code in jslint to see what other errors may be causing problems.

artlung
A: 

It seems that IE is not returning anything with val().

Dirk Zaal