Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: dynamodb pagination nodejs 
Javascript :: ok that is something 
Javascript :: how to merge two objects into one in javascript 
Javascript :: how to delete cookie node js 
Javascript :: get left position based on container jquery 
Javascript :: change class Name in react 
Javascript :: concat js mdn 
Javascript :: js how to round up 2 decimal places 
Javascript :: regex remove spaces 
Javascript :: check how many files in a folder js 
Javascript :: get the last day of the month in js 
Javascript :: delete a node in dom javascript 
Javascript :: javascript button add input to list item 
Javascript :: string to json js 
Javascript :: inc a value mongoose 
Javascript :: file extension name in js 
Javascript :: for loop set timeout 
Javascript :: CREATE A BUTTON THAT INCREMENTS A COUNTER WHEN CLICKED 
Javascript :: new line javascript 
Javascript :: Downward Triangle Star Pattern in JavaScript 
Javascript :: how to enable click copy function using js 
Javascript :: jquery find index of this 
Javascript :: javascript competitive programming 
Javascript :: set node_env in windows 
Javascript :: link href javascript 
Javascript :: how to play background sound js 
Javascript :: tonumber javascript 
Javascript :: random code generator 
Javascript :: laravel ajax post data to controller 
Javascript :: javascript remove query string from url 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =