Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When I click on the button it shows me an error

The error ReferenceError: b is not defined at HTMLButtonElement.onclick (/:32:30)

 let s;
function b(){
      s = document.getElementById(k).innerHtml;
      animates();
}
        <form class="form">
         <label>How much do you want to donate</label>
          <input type="number" id="k">
    <button id="l" onclick="b()">Cal</button>
    
        </form>


   

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

no need to do a form for this, also inline events are not preferred use eventListeners in js.

NOTE: I’ve put input’s value as result, but you didn’t say what you exactly want, so I think this will work with you anyway

document.getElementById('l').addEventListener('click', function() {
  document.getElementById('result').innerHTML =document.getElementById('k').value;
})
<label>How much do you want to donate</label>
<input type="number" id="k">
<button id="l">Cal</button>
<p id="result"></p>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading