[위 에] 2 자 바스 크 립 트 저장 데이터

가격 을 계산 하 는 예
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript"> //javascript     //Number:  ,      ; //Boolean:true false; //Text:   ; //  :   。 //  :     。 // function updateOrder() { //    :   const(        const) //const taxRate = 0.0925; //   //const donutPrice = 0.50; //   //    :   var,"="       //      ,             var taxRate = 0.0925; //   var donutPrice = 0.50; //   var numCakeDonutForDa = document.getElementById("cakedonuts").value.toString(); // if (numCakeDonutForDa.indexof(" ")!=-1) { // ... // } var numCakeDonut = parseInt(document.getElementById("cakedonuts").value); var numGlazedDonuts = parseInt(document.getElementById("glazeddonuts").value); //undefined     //NaN     if (isNaN(numCakeDonut)) {//          numCakeDonut = 0; } if (isNaN(numGlazedDonuts)) { numGlazedDonuts = 0; } //                  //        ,    ;   、   、_ $  ;           ;           //            :myName //      var subTotal = (numCakeDonut + numGlazedDonuts) * (parseFloat(donutPrice)); //           var tax = parseFloat(subTotal) * parseFloat(taxRate); var total = parseFloat(subTotal) + parseFloat(tax); //getElementById         document.getElementById("subtotal").value = "$" + subTotal.toFixed(2); document.getElementById("tax").value = "$" + subTotal.toFixed(2); document.getElementById("total").value = "$" + total.toFixed(2); } //      0  ,      function checkOrder() { if (document.getElementById("cakedonuts").value == "" || document.getElementById("glazeddonuts").value=="") { alert("      "); } } </script>
</head>
<body id="frame">
    <form name="orderForm" action="HTMLPage1.htm" method="post">
    <div class="field">
        #        <input type="text" id="cakedonuts" name="cakedonuts" value="" onchange="updateOrder()" />
    </div>
    <div class="field">
        #        <input type="text" id="glazeddonuts" name="glazeddonuts" onchange="updateOrder()" />
    </div>
    <div class="field">
        #    <input type="text" id="subtotal" name="subtotal" onchange="" />
    </div>
    <div class="field">
        #   <input type="text" id="tax" name="tax" onchange="" />
    </div>
    <div class="field">
        #   <input type="text" id="total" name="total" onchange="" />
    </div>
    <input type="button" id="check" value="  " onclick="checkOrder()" />
    </form>
</body>
</html>

좋은 웹페이지 즐겨찾기