...

View Full Version : Toggling visibility w/Javascript



kraftomatic
10-21-2003, 04:36 PM
Hey All,

I have this function, which toggles the visibility of a drop down menu. This currently works:

function toggleOther(chosen) {
if (chosen == 'Warren') {
document.myForm.WarrenBldg.style.visibility = 'visible';
document.myForm.WarrenBldg.value = 'East';
} else {
document.myForm.WarrenBldg.style.visibility = 'hidden';
document.myForm.WarrenBldg.value = '';
}
}


<select name="OfficeLocation" class="textbox" onChange="toggleOther(document.myForm.OfficeLocation.options[document.myForm.OfficeLocation.selectedIndex].value);">


I'm trying to do something similar with a simple link. If the user clicks the link once, this drop down appears. If they click it again, it disappears.

I have the right idea I think, but the wrong code/syntax.

Any help would be appreciated.

Thanks.

A1ien51
10-21-2003, 08:36 PM
I persoannly would do it this way


function toggleOther() {
showHide='visible';
theText = '';
if(document.myForm.WarrenBldg.style.visibility == 'visible'){
showHide = 'hidden';
theText = 'East';
}

document.myForm.WarrenBldg.style.visibility = showHide;
document.myForm.WarrenBldg.value = theText;
}


Call it with something with

onclick="toggleOther()"

Eric

kraftomatic
10-21-2003, 08:52 PM
got it .. thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum