I need help finding my problem in the following JavaScript calculator of mine. I can usually get an answer in the answer box but instead of the text I put into the other boxes, it has three groups of something that says something like, "[HTML Element Input]" or whatever. Anyway, here it is. Can you please help me look for a mistake? <html> <head> <title>Calculator</title> <script type="text/javascript"> function calculate() { var a=document.getElementById('num1'); var b=document.getElementById('oprate'); var c=document.getElementById('num2'); { document.getElementById('answer').value=a+b+c; } } </script> </head> <body> <form> <input type="text" id="num1" value="First number"> <input type="text" id="oprate" value="+, -, *, or /"> <input type="text" id="num2" value="Second number"> <input type="button" onclick="calculate()" value="Calculate..."> <input type="text" id="answer" value="the answer will appear here"> </form> </body> </html>
I think the main problem is that I didn't correctly assign the variables. I'm gonna look for how to do it, but if you can tell me how to use the text people put into a text area as a variable, could you please tell me?