gpt4 book ai didi

javascript - 我的代码有什么错误?我的变量的乘积未显示在总计中

转载 作者:行者123 更新时间:2023-11-30 12:22:05 24 4
gpt4 key购买 nike

<分区>

我似乎无法让 totalCost 变量显示相乘后的值。我相信 ID 或价格变量可能有问题。有没有更好的方法来编写这段代码?

<!DOCTYPE html>
<html>
<head>
<Script type="text/javascript">
function multiply() {
var hoursParked = document.getElementById('hP').value;
var price = 5.00;
var totalCost = document.getElementById('total');
var totalPayment = (hoursParked * price);
totalCost.value= totalPayment;
}
</Script>
</head>

<body>
<div align="center">
<form id="1">
<h1><p style="background-color:blue ; color:red;">Jamie's Parking Garage Payment Calculator</p></h1><hr>
<input type="text" id="customerName" name="customerName" placeholder="Please enter your name here." size="27px"><br><br>
<input type="number" id="hP" name="hoursParked" placeholder="Hours parked?" min="1" max="24"><br><br>
<input type="button" id="calculateP" name="calculatePayment" value="Calculate" onclick="multiply()"/>
<input type="reset" id="resetBtn" value="Clear"><br><br>
<input type="number" id="total" name="totalCost" placeholder="Your Total Payment" readonly/><hr>
</form>
</div>
</body>
</html>

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com