** Note: I just figured out how to call functions through functions and as such don't really need a lot of help with this. But if there is a cleaner method of doing this. Please let me know!
Okay, so I'm really new to javascript and HTML so don't hate me if I don't understand some of the basics. From what I know this code I've come up with should be working. Anyways, what I want to do is have a blank text box for someone to input text into. When they input text using the onchange command I want that textbox's new value to be the trigger for a button to show up using the "if" statement in Javascript.
For example: If someone inputs into the test box the word "test". When they click outside of the box again I would like a button to show up (what it says is irrelevant). But if they put anything else that isn't equal to the word "test" it won't show a button up.
This is the following code I have.
<html>
<head>
<script>
window.onload=function(){
document.getElementById("button").style.display='none';
}
function textCheck(){
if (document.getElementById("userText").value == "test") alert("hello");
}
</script>
</head>
<body>
<input type="button" id="button" value="New Button"/>
<input type="text" id="userText" onchange="textCheck()"/>
</body>
</html>
I will note that the previous code was done in part with help from other stackoverflow searches. However, this gives me an alert. What I want is a button. So instead of the alert line I need it to run another function to show the button.
Would this following code work?
}
function showButton(){
document.getElementById("button").style.display='block';
}
And if so, how do I replace the alert with code to run a second function? If anyone has any better ideas it would be greatly appreciated.