Skip to content

Instantly share code, notes, and snippets.

@evdokimovm
Created April 28, 2016 01:01
Show Gist options
  • Save evdokimovm/8bad6e88b73769edcbc15594bbfe209d to your computer and use it in GitHub Desktop.
Save evdokimovm/8bad6e88b73769edcbc15594bbfe209d to your computer and use it in GitHub Desktop.
Passing HTML input value as a JavaScript Function Parameter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
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 type="text/javascript">
function add(a, b) {
var sum = parseInt(a) + parseInt(b);
alert(sum);
}
</script>
</body>
</html>
@mitm786
Copy link

mitm786 commented Jun 20, 2020

<title>multiple parameters function javascript</title>

Click <script type="text/javascript"> function myfunctionName( name,age ){ document.getElementById("result").innerHTML += name; document.getElementById("ageshow").innerHTML += age; } </script> more learn about main points with the example of [How to Pass Parameter in JavaScript Function From Html](https://wlearnsmart.com/how-to-pass-parameter-in-javascript-function-from-html/)

@motibytes
Copy link

<3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment