How can I make a value of an input text to vanish after pressing a button? this is the code i wrote but it doesn't work.. <html> <head> <script type="text/javascript"> function regel(z) { var x=document.getElementById(z) x.style.visibility="hidden"///i thought thi should do the job.. } </script> </head> <body> <input type="text" id="t1" style="width:200px; height:200px;"> <input type="button" value="right->>" onclick="regel('t1')"> </button> </body> </html> Code (markup): need u quickly!!!
if you want the value of an input to vanish... document.getElementById("t1").setAttribute("value", "");
your code? no idea, why not use firebug to troubleshoot it? you can always do: console.log(x.style) and see if it is indeed a style collection. otherwise, just tested: <input id="t1" value="arse" /> <script language="JavaScript"> document.getElementById("t1").setAttribute("value", ""); </script> PHP: works fine
Like symbol said. <html> <head> <script type="text/javascript"> function regel(z) { document.getElementById(z).value = ""; // will change to an empty string } </script> </head> <body> <input type="text" id="t1" style="width:200px; height:200px;"> <input type="button" value="right->>" onclick="regel('t1')"> </button> </body> </html> Code (markup):