<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>JavaScript Multiple inputs</title>
</head>
<body>
<div class="">
<input type="number" max="5" min="1" name="input1" value="0" placeholder="0"><br>
<input type="number" max="5" min="1" name="input2" value="0" placeholder="0"><br>
<button type="button" name="button" onclick="calculate()">test</button><br>
<span id="output"> output is </span>
</div>
<script type="text/javascript">
function calculate() {
var input1 = getElementsByName('input1').value ;
var input2 = getElementsByName('input2').value ;
getElementsById('output').innerHTML = (2*input1) + (input2/2) ;
}
</script>
</body>
</html>
I want to make an output based on multiple outputs. In this script, I want to make some calculations of the inputs of the user. However, every time I try to run the code the output does not show any result (I am a beginner).