Answers for "passing html vlaues to Javascript function"

1

passing html vlaues to Javascript function

<body>
<h1>Adding 'a' and 'b'</h1>

  a: <input type="number" name="a" id="a"><br>
  b: <input type="number" name="b" id="b"><br>
  <button onclick="add(document.getElementById('a').value,document.getElementById('b').value)">Add</button>

<script>
  function add(a,b) {
    var sum = parseInt(a) + parseInt(b);
    alert(sum);
  }
</script>
</body>
Posted by: Guest on April-28-2020

Code answers related to "passing html vlaues to Javascript function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language