<script>
function doMath() {
var labor = parseInt(document.getElementById('prod_price').value);
var tax = labor * .10;
document.getElementById('prod_description').value = tax;
}
</script>
<div>Price: <input type="text" id="prod_price" onBlur="doMath();" /></div>
<div>Tax: <input type="text" id="prod_description" readonly="true" /></div>
如何制作这个...如果价格低于100,那么税必须显示为5 如果价格高于100,那么税必须是20
答案 0 :(得分:0)
试试这个..
function doMath() {
var labor = parseInt(document.getElementById('prod_price').value);
if(labor<100)
{
document.getElementById('prod_description').value = "5";
}
else if(labor>100)
{
document.getElementById('prod_description').value = "20";
}
}