javascript question

handlewithbeer

Newcomer
Joined
Oct 7, 2003
Messages
15
Location
Vancouver, BC
hopefully someone can assist me with this.

trying to make it so that when one div in my html page is hidden, another one is visible. tried this

function hideShow(first,second)
{

var div1 = document.getElementById(first).style;
var div2 = document.getElementById(second).style;

div1.display = div1.display? "block":"";
div2.display = div2.display? "":"block";
}

not sure how to proceed.

any help greatly appreciated.

thanks.
 
Code:
function toggle(id)
{
   var div = document.getElementById(id);
   div.style.display = (div.style.display == "none") ? "inline-block" : "none";

   // you could also try this...
   // div.style.visibility = (div.style.visibility == "hidden") ? "visible" : "hidden";
}

function hideShow(first,second)
{
  toggle(first);
  toggle(second);
}
 
Back
Top