Forum Moderators: open

Message Too Old, No Replies

DIV Replace

hide one div and real another at the same time

         

Franco_UK

3:58 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



Hi all,

So close with this one but just can't quite get it right. I have a simple 2 column page, nav buttons on the left and text on the right, couldn't be simpler (all built in CSS)

I want the text on the right to be replaced as the user clicks each nav button. Each text has it's own div.

I can easily hide the first div on click using the following js:

function RemoveContent(d) {
document.getElementById(d).style.display = "none";
}

but how do I make the next text div appear in it's place? I would normally use js here:

function InsertContent(d) {
document.getElementById(d).style.display = "";

but I want it to set the first div to display:none
and set the second div to display:"" all at the same time...

I bet this is real simple, hope so!

Franco_UK

...Proud owners of the worst cricket team in the world...

Dabrowski

5:14 pm on Apr 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well... yes it is.

Just put both lines in the same function, with a slight modification, as follows.

function SwapContent( old, new) {
document.getElementById( old).style.display = "none";
document.getElementById( new).style.display = "";
}

Not sure if

display = "";
will work though, might have to use
display = "block";