簡體   English   中英

價格從數量變化

[英]Price change from quantity

嗨,我已經寫了一個簡單的表格數學設置,但是我意識到它需要更改,基本上我需要創建的東西可以檢測出,如果成人票是10或更大,每張票的價格是7美元而不是10美元,但是如果它是9美元或以下每張票仍為$ 10

 <form name="newshow" id="newshow" action="test.php" method="post" oninput="totalamount.value = Math.round(adult.value * 10) + Math.round(student.value * 7); changedue.value = Math.round(moneygiven.value - totalamount.value);"> <fieldset> <select name="showtime" > <option value="" disabled="disabled" selected="selected">Performance</option> <option value='1' type="number" >Show 1 </option> <option value='2' type="number" >Show 2 </option> <option value='3' type="number" >Show 3 </option> </select> <h4>Ammount of Adults</h4> <input name="adult" id="adult" type="number" > <br /> <h4>Ammount of Students</h4> <input name="student" type="number" > <br /> <h4>Money Owed</h4> <input name="totalamount" readonly="1"> <br /> <h4>Money Given</h4> <input name="moneygiven" type="number" > <h4>Change due</h4> <input name="changedue" readonly="1"> <input type="submit" /> </fieldset> </form> 

我不知道從這里去哪里,但我假設這將通過腳本而不是我當前使用的“ oninput”來完成

嘗試這個。 這將檢查成人票是否> = 10

 <form name="newshow" id="newshow" action="test.php" method="post" oninput="totalamount.value = ((adult.value >= 10) ? Math.round(adult.value * 7) : Math.round(adult.value * 10)) + Math.round(student.value * 7); changedue.value = Math.round(moneygiven.value - totalamount.value);"> <fieldset> <select name="showtime" > <option value="" disabled="disabled" selected="selected">Performance</option> <option value='1' type="number" >Show 1 </option> <option value='2' type="number" >Show 2 </option> <option value='3' type="number" >Show 3 </option> </select> <h4>Ammount of Adults</h4> <input name="adult" id="adult" type="number" > <br /> <h4>Ammount of Students</h4> <input name="student" type="number" > <br /> <h4>Money Owed</h4> <input name="totalamount" readonly="1"> <br /> <h4>Money Given</h4> <input name="moneygiven" type="number" > <h4>Change due</h4> <input name="changedue" readonly="1"> <input type="submit" /> </fieldset> </form> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM