<br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode35'));"><u>Copy code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode35"> <br><!DOCTYPE HTML PUBLIC "-//W3C/ /DTD HTML 4.01 Transitional//EN"> <br><html> <br><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <br><head> <br><title> Price calculation after discount</title> <br><!--Set the price calculation event function, take different drop-down discount numbers, and send the calculation results into the text box--> ; <br /><script type="text/javascript"> <br>function calculator(){ <br>var prices=document.getElementById("price"); <br>var discounts=document.getElementById(" number"); <br>var pay; <br>var select=document.getElementById("payfunction"); <br>if((prices.value>=0&&!isNaN(prices.value))&&(discounts.value> ;=0&&!isNaN(discounts.value))&&prices.value!=""&&discounts.value!="") <br>{ <br>pay=prices.value*discounts.value; <br>switch(parseInt( select.value)){ <br>case 1:pay=pay*0.5; break; <br>case 2:pay=pay*0.8; break; <br>case 3:pay=pay*0.6; break; <br>} <br>document.getElementById("result").value=pay; <br>alert("Congratulations, the transaction is successful!"); <br>}else <br>{ <br>prices.focus() ; <br>prices.select(); <br>alert("Please enter the correct price and quantity (cannot be empty)! "); <br>} <br>} <br></script> <br></head> <br><!-- Define the interface format, set the drop-down table, and set the calculated price event--> ; <br /><body> <br><center> <br><form name="discount" action="result.jsp" method="post"> <br>Bidding price: <input type ="text" id="price" style="width: 150px"/><br> <br>Purchase quantity: <input type="text" id="number" style="width: 150px"/> ;<br /> <br />Payment method: <select id="payfunction" style="width: 150px"> <br><option value="1">Online banking payment - 50% off</option> ; <br /><option value="2">Alipay payment - 20% off</option> <br><option value="3" selected="true">Q coin payment - 40% off </option> <br></select><br> <br>Estimated total price: <input type="text" id="result" style="width: 150px"><br> <br><input type="button" id="allresult" value="Calculate total price" onclick="calculator()" /> <br></form> <br></center> <br> </body> <br></html> <br> </div>