Hide/Show div tags with SSJ?

Is it possible to hide/show div tags with Server Side JavaScript?

If so, can you please provide code example.

Subject: Show/Hide Div Tags

Are these normal HTML tags or xp:panels? You don’t directly have access to the rendered HTML from SSJS, but there are a number of methods you could use.

If it’s an xp:panel you can set the rendered property based on a scoped variable. In SSJS set the scoped variable and do a partial refresh of the part of the page that includes the xp:panel. If it’s a div, you need to get a bit cleverer, and set the style to a scoped variable, e.g. “style=‘#{javascript:viewScope.divStyle}’”. This SSJS will get converted at run-time to the value of the scoped variable. So you set that to e.g. display:none, change the scoped variable via SSJS when you need to and do a partial refresh of part of the page including that div.

If you’re using 8.5.1 you have the onComplete event in a partial refresh. You can use that to run CSJS after your SSJS has run. I posted a link to sample code for using that event on my blog last week. http://hermes.intec.co.uk/Intec/Blog.nsf/dx/21042010222252HERT3U.htm