开发者

IE8 parseFloat problem

in IE8 i get the following error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; Tablet PC 2.0; .NET4.0C)
Timestamp: Mon, 11 Apr 2011 12:36:39 UTC


Message: Object doesn't support this property or method
Line: 102
Char: 4
Code: 0
URI: http://www.geoffmeierhans.com/js/jquery/appone.js

The line it is referring to has the 开发者_开发技巧following code on it:

var distance = parseFloat($('#distance').val());

Anyone know why this might be happening?

Thanks


can you try this?

$('#submit').click(function() {
  var mpg= $('#mpg').val();
  if(mpg=='') {
    alert("The average cannot be empty");
    $('#mpg').focus();
    return false; // cancel submission
  } 

  if (isNaN(mpg)) {
    alert("The value you entered is not a valid number");    
    $('#mpg').focus();
    return false; // cancel submission
  } 
  mpg = parseFloat(mpg);
  if (mpg==0) {
    alert("MPG cannot be 0"); // or you will divide by 0 later    
    $('#mpg').focus();
    return false; // cancel submission
  } 
  var distance = $('#distance').val();
  distance = isNaN(distance)? 0: parseFloat(distance);
  var costlitre = $('#costlitre').val()
  costlitre = isNaN(costlitre)?0: parseFloat(costlitre);

  // Work out litres needed
  if(symbol=='$') {
    gallons = distance / mpg;
    cost = gallons * costlitre
    cost = cost.toFixed(2);
  } else {
    gallons = distance / mpg;
    litresneeded = gallons * litres;
    cost = litresneeded * costlitre;
    cost = cost.toFixed(2);
  }
  $('#total').html(symbol+cost);
  $('#four').fadeOut("slow", function() {
    Cufon.replace('h1, p, .tip, #units, #price, #total', { color: '-linear-gradient(#fff, #fff)'});
    $('#five').fadeIn("slow");
  });
  return false; // cancel submission - change to true to submit
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜