Horje
banking program deposit and withdrawal using ajax call Code Example
banking program deposit and withdrawal using ajax call
<!DOCTYPE html>
<html>

  <head>
    <script  src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  </head>

  <body>
    <div id="checking" class="account">
      <h2>Checking</h2>
      <div id="checkingBalance" class="balance">$0</div>
      <input id="checkingInput" class="input" type="text" value="0" placeholder="enter an amount" />
      <input id="checkingDeposit" class="deposit" type="button" value="Deposit" />
      <input id="checkingWithdraw" class="withdraw" type="button" value="Withdraw" />
    </div>
    <div id="savings" class="account">
      <h2>Savings</h2>
      <div id="savingsBalance" class="balance">$0</div>
      <input id="savingsInput" class="input" type="text" placeholder="enter an amount" value="0" />
      <input id="savingsDeposit" class="deposit" type="button" value="Deposit" />
      <input id="savingsWithdraw" class="withdraw" type="button" value="Withdraw" />
    </div>
    <script>
    $(function() {
      $("#checkingBalance").on("click", function() {
        var checkingBalance = parseInt($(this).text().replace("$", "")); 
        console.log("This is the checking balance. ", checkingBalance); 
        var deposit = parseInt($("#checkingInput").val()); 
        console.log("This is the deposit: " + deposit);
        var total = deposit + checkingBalance; 
        console.log("This is the total: " + total); 
        $("#checkingBalance").html("$" + total);
        if (total > 0) {
          $("body").removeClass("zero")
        }
      })
    });
  </script>
  </body>

</html>




Javascript

Related
js multiple url fetch Code Example js multiple url fetch Code Example
js draw box Code Example js draw box Code Example
how to convert variable to string in jquery Code Example how to convert variable to string in jquery Code Example
how to style svgs in react Code Example how to style svgs in react Code Example
service erstellen angular Code Example service erstellen angular Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7