0

needing help with homework - calculator using javascript

i need to grab the text from the <input> and use that number in the equation.

<script>
function runMe(){
var x == document.getElementById('input1').value;
document.write(x);
}
</script>

<body>
<form>
Enter number <input type="text" id="input1" value="">
<input type="submit" onClick="runMe">
</form>

</body>

Edited by pritaeas: Moved.

3
Contributors
3
Replies
22
Views
3 Years
Discussion Span
Last Post by AndrisP
0

You should be using one "=" to set a variable. Using double "==" is for comparison, like using in an IF statement to check if x == this.

var x = document.getElementById('input1').value;

Not really sure what you're doing with document.write(x); either.

Edited by pixelsoul

0

in line 11 <input type="submit" onClick="runMe"> change to <input type="submit" onclick="runMe()" />

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.