Wednesday, September 27, 2006

Show/Hide html elements

Lot of sharepoint beginners have a problem in hiding the toolbar from the other users while rendering the page. This can be acheived by applying a style or a javascript to the element they want to hide.

The toolbar is always placed inside a column on a table. So the first method is applying a style to the column.

<!-- Column where the the toolbar is -->
<td style="display:none">


Or the second method where writing a javascript.

<script language="javascript">
document.getElementById(<column id>).style.display = 'none';
</script>


These two can apply to hide any element in a html file. But what if we want to display when its necessary or to display with a click event. For that, here goes the script;

<script language="javascript">
document.getElementById(<column id>).style.display = 'inline';
</script>


Simple isn't it? :)

Cheers!

No comments: