Tuesday, December 23, 2008

How to hide control using javascript?

The answer written in the first response is not actually 100% accurate.

We can hide/display the controls using

1) document.getElementById("").style.display="none"/document.getElementById("").style.display="inline"

or

2)
document.getElementById("").style.visibility="visible";/document.getElementById("").style.visibility="hidden";

The difference between the two is using the 1st option, we can hide the control and the space occupied by the controls also gets
removed, i.e if the controls has a certain height and is contained in a table row, the row gets collapsed and when displayed, the control will again take it's place.and the row will again retain its height by displaying the control in it.

On the other hand if we use 2nd option, the control will get hide
but the space occupied by the control will remain as it is and the row will not collapse, i.e the row will still be displayed
as blank containing the control in hidden mode.

From http://www.dotnetspider.com/resources/6563-How-hide-control-using-javascript.aspx

No comments: