This is a problem that I don't understand because all the code validates. It's my homework that's due tonight at Midnight.
When I enter a value into the 'Price' text box and hit enter I get the $isNaN in the 'Total' textbox. Any suggestions. Here is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4 /loose.dtd">
<html>
<head>
<title>Price Calculator</title>
<script type="text/javascript">
function fixOrder()
{
var numPrice = parseFloat(document.getElementById("cost").value);
var taxP = parseFloat(document.getElementById("tax").value);
//var total = parseFloat(document.getElementById("total").value);
if (isNaN(numPrice)){
alert("Sorry,you must enter a numeric value to place order");
if (isNaN(taxP))
alert("Sorry, you must enter a numeric tax value to continue");
}
var tax = (numPrice * taxP)/100;
var total = numPrice + tax;
document.getElementById("total").value = "$" + total.toFixed(2);
}
</script>
</head>
<body bgcolor="#00f3F1">
<h1 align="left">Price Calculator</h1>
<form name="form">
<p>
Price: <input type="text" id="cost" name="cost" value="" onchange="fixOrder();"/>
</p>
<p>
Tax: <input type="text" id="tax" name="tax" value="" onchange="fixOrder();"/>
</p>
<p>
Total: <input type="text" id="total" name="total" value="" disabled="disabled();"/>
</p>
</form>
</body>
</html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…