I have a website featuring 2 text boxes, a button, and a paragraph. What I would like to do is have users input a number into textbox1, another number into textbox2, and then click the "calculate" button. Upon doing so, a statement should appear indicating whether the second number is lower, higher, or equal to the first number entered in textbox1. The code below is what I've tried, but it's not functioning as expected - it consistently returns the same result.
<input type="text" id="textbox1" value="Enter a number" onfocus="javascript:this.value='';">
<input type="text" id="textbox2" value="Enter another number" onfocus="javascript:this.value='';">
<button onclick="calculate()">Calculate</button>
<p id="demo"></p>
<script>
function calculate(){
var x="";
if (textbox1 > textbox2){
x="more than";
}
else if (textbox1 = textbox2){
x="Same";
}
else{
x="Lower";
}
document.getElementById("demo").innerHTML=x;
}
</script>
Can anyone help me figure out why? Thank you!