Reputation: 1
I want to combine these two blocks in the script. I want it so that when you type river into the text box i can give a good job statement or post a link.
I don't know what to use as the variable in the second statement. Which is the if statement.
var userInput.value=river;
if(userInput.value)=="river"){
document.write("hey");
}
<br/>
function changeText2(){
var userInput=document.getElementById('userInput').value;
document.getElementById('boldStuff2').innerHTML=userInput;
}
</script>
<p>What has a mouth but can't chew?<b id='boldStuff2'>???</b></p>
<input type='text' id='userInput' value='Enter Answer Here'/>
<input type='button' onclick='changeText2()' value='Answer'/>
</head>
</html>
Upvotes: 0
Views: 683
Reputation: 7668
se this function in your JScript code
function changeText2(){
var userInput=document.getElementById('userInput').value;
if(userInput=="river")
{
document.write("");
}
document.getElementById('boldStuff2').innerHTML=userInput;
}
Upvotes: 0
Reputation: 46900
First three lines of that code are not only wrong logically, they are unnecessary as well. Try a simple version
<script>
function changeText2(){
var userInput=document.getElementById('userInput').value;
if(userInput.toLowerCase()=="river")
{
alert("Good Job");
}
document.getElementById('boldStuff2').innerHTML=userInput;
}
</script>
<p>What has a mouth but can't chew?<b id='boldStuff2'>???</b></p>
<input type='text' id='userInput' value='Enter Answer Here'/>
<input type='button' onclick='changeText2()' value='Answer'/>
</head>
</html>
Upvotes: 1