It's actually very simple. ALL values taken from form elements (input elements in your case) are strings, not numbers.
In order to do math with them, you must first convert them to numbers.
Modify your line to use the parseInt() JavaScript function:
x(parseInt(input,10), parseInt(input2,10));
A better way to structure your code would be to not store the values of the input elements, but to store references to the elements themselves. That way you can keep referencing the objects over and over without having to scan for them over and over.
input = document.getElementById("inputText");
input2 = document.getElementById("inputText2");
var input1Num = parseInt(input.value, 10);
var input2Num = parseInt(input2.value, 10);
x(input1Num, input2Num);
Finally, as others have pointed out, some of your HTML is incorrect as you have markup like this:
</br>
and
<input type="Submit" id="submitText" value="Submit" </input>
Both of these errors are rooted in the misunderstanding of what elements must be terminated and what elements may not be explicitly terminated with a closing tag. Along with this is the (legal but largely irrelevant these days) syntax of "self-terminating" elements, which is a form of syntax that is used in a variant of HTML called XHTML. While this syntax is legal in HTML5, I highly discourage its use. For details on why, read my post here.
So finally, a finished version of the code would be:
// Get references to the DOM elements you'll need (not properties of the objects)
var input1 = document.getElementById("inputText1");
var input2 = document.getElementById("inputText2");
var output = document.getElementById("output");
var btn = document.getElementById("submitText");
// Wire up the button to run your function when it's clicked
btn.addEventListener("click", function(){
// Only get the input values when you need to run your function
var input1Num = parseInt(input1.value, 10);
var input2Num = parseInt(input2.value, 10);
// Call the function and pass it the values it needs
output.textContent = x(input1Num, input2Num);
});
function x(par, strokes) {
// You are going to return a string no matter what
var result = "";
if (strokes == 1) {
result = "Hole-in-one!";
} else if (strokes <= par - 2) {
result = "Eagle";
} else if (strokes == par - 1) {
result = "Birdie";
} else if (strokes == par) {
result = "Par";
} else if (strokes == par + 1) {
result = "Bogey";
} else if (strokes == par + 2) {
result = "Double Bogey";
} else if (strokes >= par + 3) {
result = "Go Home!";
}
// Now just return once:
return result;
}
<br>
Input Par
<input type="number" id="inputText1">
<br>
Input Strokes
<input type="number" id="inputText2">
<br>
<!-- Just use a regular button here, since you aren't actually
submitting any form data anywhere -->
<input type="button" id="submitText" value="Submit">
<div id="output"></div>
</br>. There's nothing like that!!!