Teodor
Teodor

Reputation: 1305

Jquery problem with IE working fine in FF

Hello i have this code that works perfect in Firefox but in IE 8 doesn't work and doesn't give me any error ?!

$(".shp_div").change(function () {
  var str = "";
  $("select option:selected").each(function () {
       var countprod =parseInt($("#countprod").val());
        var str2 = $(this).val();
        str2_array = str2.split('|');
        var cost = parseInt(str2_array[0]);
        var cost_extra = parseInt(str2_array[1]);
        if ($("#countprod").val()>1) {
        str = parseInt(((countprod-1)*cost_extra) + cost);
        } else{
        str = cost;
      }});
  $(".csq_item2").text(str);
   var total =parseInt($("#subtotal").val());
  var shipping=parseInt(str + total);
  $(".price_total").text(shipping);
})
.change();

In order to get "full picture" please go at : http://poshsunglasses.net/21-Bottega_Veneta-B.V.88.html and add to cart the prod and then in the cart page try to select the Shipping country in FF make the calculation in IE no.

thank you

Upvotes: 0

Views: 88

Answers (2)

Teodor
Teodor

Reputation: 1305

I changed

$(".shp_div").change(function () {

with

$(".shippinginfo").change(function () {

and is working

Upvotes: 0

Nealv
Nealv

Reputation: 6884

Your problem is that you bind the change event to the DIV. div's don't really have a change event. Maybe in FF and chrome the selection change event leaks trough to the div but in IE it doesn't.

Try putting the change event on the select (or another input) instead of a div.

BTW: why do you do a foreach on the select ? when you can only select one?

I would do this: give mu selectlist an id:

<select name="shipping" id="shipping">

$("#shipping").change(function () {
    var str2 = $("option:selected","#shipping").val().split('|');
    var cost = parseInt(str2_array[0]);
    var cost_extra = parseInt(str2_array[1]);
    //Go on from here
});

PS: If you are going to use any value in your selectlist as information you send to the backend. I would use a Unique ID instead of this notation to prevent problems, and put the price value in an extra parameter:

<option value="56411-416(unique ID)" price="25|10">Country</option>

Upvotes: 3

Related Questions