当我点击计算按钮时,我似乎无法获得输出。我知道我错过了一些简单的事情,但是我整天都在绞尽脑汁,似乎无法让它正常工作。这是我更新的代码,仍然无法正常工作。
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function calc(){
var price = document.getElementById("price");
var shipping=parseFloat(calc(price));
var total= price+shipping;
if (price<=25){
return 1.5;
}
else{
return price*10/100
}
window.alert("Your total price with shipping and handling is $" + price + ".");
}
</script>
</head>
<body>
<form name="total" action="">
Enter your amount:
<input type="text" name="price" id="price">
<input type="button"
value="calculate"
onclick="calc(document.getElementById("price")">
</form>
</body>
</html>