JavaScript in Google Chrome
What's the reason why some JavaScript functions won't work in Google Chrome but works fine in Mozilla Firefox?
Like this..
HTML code:
...onkeyup="calculateTotal(this.value)"
onclick="clickclear(this, '0')" onblur="clickrecall(this,'0')" value="0"
JS code:
function calculateTotal(price, quantity, cnt) {
if(quantity != ""){
var totalAmt = parseInt(document.getElementById('total['+cnt+']').value);
totalAmt = parseInt(quantity) * parseInt(price);
开发者_如何转开发 document.getElementById('total['+cnt+']').value = totalAmt;
document.getElementById('indicator').value++;
}
else{
document.getElementById('total['+cnt+']').value = 0;
document.getElementById('indicator').value--;
}
}
And already included this:
jquery1.4.2.jsYou're calling the function
calculateTotal(this.value)
but your function is:
function calculateTotal(price, quantity, cnt)
I don't know why this DOES work in Firefox (I'm assuming they automatically supplied parameters or something), but your two functions do not match up.
From the html 4 spec:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
http://www.w3.org/TR/html401/types.html#type-name
I would therefore replace your use of square brackets in ids before trying anything else.
精彩评论