I’m teaching myself basic Javascript and trying to figure out how to do math with values a user enters in a form.
This is what I have so far, but I’m clearly using the wrong kind of forumula because it’s concatenating the digits rather than adding the numbers. I’ve also tried changing the types of the three input fields between “text” and “number”, to no avail.
<form name="thing" id="calculator">
A <input type="number" name="inputa" size="16" class="display">
<br>
B <input type="number" name="inputb" size="16" class="display">
<input type="button" name="dothething" value="add them" OnClick="thing.output2.value = eval(thing.inputa.value + thing.inputb.value)">
<br>
A+B=<input type="text" name="output2" size="16" class="display">
</form>