Some more handy Javascript (depends on Prototype):
function toggleByClass(id, className, callback){
// shows the element with id 'id'
// and hides all other elements with class 'className'
$A($$('.'+className)).each(function(element){
$(element).style.display = "none";
})
if(id) // call it with a false id to hide all
$(id).style.display = "block";
if(callback)
callback(id, className);
}
function toggleById(id1, id2){
var a = $(id1).style;
var b = $(id2).style;
if(a.display == 'none' || a.display == ''){
a.display = 'block';
b.display = 'none';
}else{
a.display = 'none';
b.display = 'block';
}
}
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):