Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Html and JavaScript result flash and goes of immediately what could be the problem

Html

    <!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
    </head>
    <body>
        <h1> Welcome to Benjamin's bank. Have some Money</h1>
        <p>Please enter your name, password and the amount you want to withdraw</p>
        <form action="" method="post">
            <input type="text" value="name" id="name"><br>
            <input type="password" value="password" id="password"><br>
            <input type="text" value="amount" id="amount"><br>
            <button onclick="withdraw()">click me</button>
        </form>
        <p id="para"></p>
        
        <script src="Beginners_bank.js" async defer></script>
    </body>
</html>

Javascript

    function withdraw(){
    var namevar= document.getElementById("name").value;
    var passwordvar=document.getElementById("password").value;
    var amountvar=document.getElementById("amount").value;
    var Amount=3000;
    var name="Benjamin Anoruo";
    var pass="testing123";
    var n=Amount-amountvar;
    if(namevar==name && passwordvar==pass ){
        if(amountvar<=Amount){
            document.getElementById("para").innerHTML="your withdrawal was successful. your new balance is:"+n;
            document.body.style.backgroundColor='green';
        }
    }
}

This code is supposed to take users name password and amount they want to withdraw.anytime I enter every detail and click the button it just flashes the output and return an empty form Please how can I fix this issue.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

just add type="button" to your button

about 4 years ago · Juan Pablo Isaza Report

0

Just like @Hyperella noted, hitting enter causes the page to refresh, that's what's causing the flash. To prevent that do as he's showed.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!