pass value to javascript function from html at the typing code example
Example 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>
Example 2: javascript function with input value
<button class="btn btn-primary" onclick="transmit({search: document.getElementById('search_id').value});">
<span class="glyphicon glyphicon-search"></span>
</button>