...

View Full Version : How to make a textBox invisible using javascript



murali1983
12-06-2006, 09:18 AM
hi

i want to make my textbox invisible in certain cases, is it possible to do using javascript or by any other means

thnx
Murali.

brandonH
12-06-2006, 09:31 AM
yes it is.


you can change the style of the object like so:


<input type=text id=text1>
<input type=button value=hide onclick=hide()>
<input type=button value=show onclick=show()>
<script type=text/javascript>
function hide(){
document.getElementById('text1').style.visibility='hidden';
}
function show(){
document.getElementById('text1').style.visibility='visible';
}
</script>


the above is not cross-browser friendly though, as different browsers require different values to be set to the visibility.

however comma though......

you can change the display of the object:
document.getElementById('text1').style.display="none"; //for hide
document.getElementById('text1').style.display="block"; //for show


there is a difference in the two ways. changing the objects visibility does just that, it still takes up the space it would if it were visible. where changing the display of an object hides it and all other objects around it fill in the space.

murali1983
12-06-2006, 12:08 PM
thank you..brandon :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum