Ghost Answer Ghost Answer - 3 months ago 15
Javascript Question

javascript button show/hide on text changed

I want to show and hide a button by using java script.

My problem is that the button should be hide on page load and when I changed the text in text box then button should be show.

thanks.....

Answer

pls, Check this page and tell if this is what you wanted.

Basically, you need to use onchange event to do whatever you want to do.

<html>
<head>
<script>
window.onload=function(){
  document.getElementById("button").style.display='none';

}
function showButton(){
  document.getElementById("button").style.display='block';
}
</script>
</head>
<body>
<input type="button" id="button" value="New Button"/>
Change the text in Input Box. Then Button will be show<br/><br/>
<input type="text" id="userText" value="Change the text" onchange="showButton()"/>
</body>
</html>