+ 2
1.What's error? 2.Can we compare words?
I am confused in conditional statements. Please help me. https://code.sololearn.com/Wbr8S0h9ww5n/?ref=app
1 Answer
+ 3
Add in the form tag:
<form onsubmit="myapp();">
And change the js code to:
function myapp(){
var x=document.getElementById("ok").value;
if(x=="ok"){
alert("hello");
}
else if(x=="how") {
alert("else if");
}
else {
alert("else");
}
}
The form tag needs some more things for correct running. For more info please see here:
https://www.w3schools.com/tags/tag_form.asp