Click to See Complete Forum and Search --> : Can the following .......


Tasmanian Devil
05-29-2003, 01:24 PM
Can the following script be done with just one button rather than two?

<form id="form1" action="" onsubmit="">
<input type="button" value="Show Menu" onclick="document.getElementById('menuFrame').style.visibility='visible';"/>
<input type="button" value="Hide Menu" onclick="document.getElementById('menuFrame').style.visibility='hidden';"/>
</form>
<iframe src="maenupage.html" style="width:20%;height:80%;visibility:hidden;" frameborder="0" name="menuFrame" id="menuFrame"></iframe>

Thanks

khalidali63
05-29-2003, 01:34 PM
Yes you can do that like this


<script type="text/javascript">
<!--
function Process(obj){
var frm = document.getElementById("form1");
var len = frm.length;
if(obj.value=="Show Menu"){
document.getElementById('menuFrame').style.visibility='visible';
obj.value="Hide Menu"
}else if(obj.value=="Hide Menu"){
document.getElementById('menuFrame').style.visibility='hidden';
obj.value="Show Menu"
}
}
//-->
</script>
</head>
<body class="body">
<form id="form1" action="" onsubmit="">
<input type="button" value="Show Menu" onclick="Process(this);"/>
</form>
<iframe src="maenupage.html" style="width:20%;height:80%;visibility:hidden;" frameborder="0" name="menuFrame" id="menuFrame"></iframe>

Charles
05-29-2003, 02:07 PM
Since that will give you a page that won't work an awful lot of the time, you will need your IFRAME to default to "visible" and you will want your button to only appear when it is going to work.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
<!--
function Process(obj){
if(obj.value=="Show Menu"){
document.getElementById('menuFrame').style.visibility='visible';
obj.value="Hide Menu"
}else if(obj.value=="Hide Menu"){
document.getElementById('menuFrame').style.visibility='hidden';
obj.value="Show Menu"
}
}

if (document.getElementById) document.write('<input type="button" onclick="Process(this)" value="Hide Menu">');
//-->
</script>

<iframe src="http://www.w3.org/" style="width:20%; height:80%; visibility:visible;" name="menuFrame" id="menuFrame"></iframe>

Tasmanian Devil
05-30-2003, 12:31 PM
Why can't the IFrame be hidden rather than visible?

khalidali63
05-30-2003, 12:58 PM
Nevermind him..its his habbit to make things difficult for people who have comparativley less experience.

Charles
05-30-2003, 06:44 PM
93% of users use MSIE 5 or 6 but only 87% of users use JavaScript. That means that for an awful lot of people out there your IFRAME will be hidden and remain hidden if it doesn't start out visible. I'm not trying to make things difficult. I'm trying to help you make your page work. Things have unintended consequences sometimes.