由於標題說我需要創建一個簡單的總價格函數。我需要將人數乘以1000,並在「totalPrice」中顯示。任何javascript/html/jquery都很棒。我有這個到目前爲止:如何創建簡單的總價格?
<html>
<body>
<form id="buyTicket" method="post">
<div>
Booking Name : <input type="text" required id="bookingName" placeholder="booking name" />
</div>
<div>
Number of persons : <input type="number" required id="numberOP" placeholder="number of persons"/>
</div>
<div>
Depature : <input type="text" required id="depature" class="datepicker" placeholder="enter depature date"/>
</div>
<div>
Return :
<input type="text" required id="return" class="datepicker" placeholder="enter return date"/>
</div>
<div id="totalPrice">Total:</div>
<div>
<button type="submit" id="buttonTicket">Buy Ticket</button>
</div>
</form>
<script type="text/javascript">
function CalculateTotal() {
var numberOP = document.getElementById('numberOP').value;
var total = numberOP * 1000;
document.getElementById('totalPrice').innerHTML = total;
}
</script>
</body>
</html>
請說明您的問題。什麼是問題?什麼不行? – tibo
你想實現什麼?目前的解決方案有問題嗎? –
是的,我看不到總價。我想看到它,它不工作。 – needhelp