PDA

View Full Version : Switch Menu behaving two different ways on one page



Shibari
06-01-2010, 12:28 AM
1) Switch Menu

2) http://www.dynamicdrive.com/dynamicindex1/switchmenu.htm

3) I am using switch menu in a table setup for a page that we make to make the Internet easier for my mom and the left column of the menu opens only one drop down at a time where as the right one you can open all the drop downs and have to click them to make them close. I have no idea why it is working this way and prefer that they would both work like the left side.

I can basically play around with the things and eventually get most of it to do what I want as I go so I know it could all probably be "prettier" and probably a lot more practical but I just really want both sides to work like the left side.

Oh and sorry about the bright colors, I was bored.
Thanks!




<html>
<head>
<style type="text/css">
<!--Large Link Colors-->
a.custom:link {
color: #B000F0;
text-decoration: underline;
font: bold;
font-family: Georgia, "Times New Roman", Times, serif;
font-size:18px;
}
a.custom:visited{
color: #B000F0;
text-decoration: underline;
font: bold;
font-family: Georgia, "Times New Roman", Times, serif;
font-size:18px;
}
a.custom:hover {
color: #F000B8;
text-decoration: underline;
font: bold;
font-family: Georgia, "Times New Roman", Times, serif;
font-size:18px;
}
a.custom:active {
color: #F000B8;
text-decoration: underline;
font: bold;
font-family: Georgia, "Times New Roman", Times, serif;
font-size:18px;
}

body {
background-color: #F00040;
}


table{
background-color: #FF5F2E;
border:5px dotted #00F038;
vertical-align: top;
text-align: center;
margin: 1px;
padding: 1px;
}
td.pictureframe {
background-image: url(../background/orchid.jpg);
background-repeat: no-repeat;
background-position: center center;
}

.menutitle{
cursor:pointer;
margin-bottom: 3px;
/*Button Background Color*/
background-color: #2ECEFF;
/*Button Text Color*/
color:#000000;
width:160px;
height:30px;
padding:5px;
text-align:center;
font-weight:bold;
border:1px solid #3CA770;
}

.submenu{
margin-bottom: 0.5em;
}

</style>

<script type="text/javascript">

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="no" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="local" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<table width="100%" height="100%" border="5">

<tr>
<td width="200px" rowspan="3" align=center valign="top">
<!-- Keep all menus within masterdiv-->
<div id="masterdiv">

<div class="menutitle" onClick="SwitchMenu('sub301')">Email</div>
<span class="submenu" id="sub301">
- <a href="notice.htm">Usage Terms</a><br>
- <a href="faqs.htm">DHTML FAQs</a><br>
- <a href="help.htm">Scripts FAQs</a>
</span>

<div class="menutitle" onClick="SwitchMenu('sub302')">FAQ/Help</div>
<span class="submenu" id="sub302">
- <a href="notice.htm">Usage Terms</a><br>
- <a href="faqs.htm">DHTML FAQs</a><br>
- <a href="help.htm">Scripts FAQs</a>
</span>

<div class="menutitle" onClick="SwitchMenu('sub303')">Help Forum</div>
<span class="submenu" id="sub303">
- <a href="http://www.codingforums.com">Coding Forums</a><br>
</span>

<div class="menutitle" onClick="SwitchMenu('sub304')">Cool Links</div>
<span class="submenu" id="sub304">
- <a href="http://www.javascriptkit.com">JavaScript Kit</a><br>
- <a href="http://www.freewarejava.com">Freewarejava</a><br>
- <a href="http://www.cooltext.com">Cool Text</a><br>
- <a href="http://www.google.com">Google.com</a>
</span>
</div>
</td>
<td height="10" align=center valign="top">
<!--Yahoo Search-->
<a class="custom" target="_parent" href="http://www.yahoo.com">Yahoo Search
</a><br>
<form action="http://search.yahoo.com/bin/search" name="f" target='_parent'>
<input name="p" size="30"> <br>
<input type="submit" value="Search"></form>
</td>
<td height="30" align=center valign="top">
<!--Google Search-->
<a class="custom" target="_parent" href="http://www.google.com">Google Search
</a><br>
<form action="http://www.google.com/search" method="get" name="f" target='_parent'>
<input type="TEXT" name="q" value="" size="30">
<br><input type="submit" name="btnG" value="Search">
</form>
</td>
<td height="30" align=center valign="top">
<!--eBay Search-->
<a class="custom" target="_parent" href="http://www.ebay.com">eBay Search
</a><br>
<form action="http://search.ebay.com/search/search.dll"target='_parent'>
<input name="p" size="30"><br>
<input type="submit" value="Search">
</form>
</td>
<td width="200px" rowspan="3" align=center valign="top">

<div id="masterdiv">
<div class="menutitle" onClick="SwitchMenu('sub201')">Site Menu</div>
<span class="submenu" id="sub201">
- <a href="new.htm">What's New</a><br>
- <a href="hot.htm">What's hot</a><br>
- <a href="revised.htm">Revised Scripts</a><br>
- <a href="morezone/">More Zone</a>
</span>

<div class="menutitle" onClick="SwitchMenu('sub202')">FAQ/Help</div>
<span class="submenu" id="sub202">
- <a href="notice.htm">Usage Terms</a><br>
- <a href="faqs.htm">DHTML FAQs</a><br>
- <a href="help.htm">Scripts FAQs</a>
</span>

<div class="menutitle" onClick="SwitchMenu('sub203')">eBay Tools</div>
<span class="submenu" id="sub203">
- <a href="http://offer.ebay.com/ws2/eBayISAPI.dll?bidderblocklogin">Block Bidder</a><br>
- <a href="http://pages.ebay.com/help/account/reporting-spoof.html">Report Spoof</a><br>
- <a href="http://resolutioncenter.ebay.com/">Unpaid Item</a><br>

- <a href="http://search.ebay.com/_W0QQtZvbQQsofindtypeZ25">Member Search</a><br>
- <a href="http://search.ebay.com/_W0QQtZvbQQsofindtypeZ25">End Auction Early</a><br><span style="font-size: x-small">(copy item number)</span><br>
</span>

<div class="menutitle" onClick="SwitchMenu('sub204')">eBay Sellers</div>
<span class="submenu" id="sub204">
- <a href="notice.htm">Usage Terms</a><br>
- <a href="faqs.htm">DHTML FAQs</a><br>
- <a href="help.htm">Scripts FAQs</a>
</span>
</div>
</td>
</tr>
<!--Direct Link Row-->
<tr height="30px">
<td height="10" align=center>
<a class="custom" href="http://www.daytongasprices.com/">Dayton Gas Prices</a>
</td>
<td height="10" align=center>
<a class="custom" href="http://dictionary.reference.com/">Dictionary</a>
</td>
<td height="10" align=center>
<a class="custom" href="http://spellcheck.net">Spell Check</a>
</td>
</tr>
<tr height="100%">
<td colspan="3" height=400 align=center valign="top" class="pictureframe">
<!--picture here-->
</td>
</tr>
</table>
</body>
</html>

ddadmin
06-01-2010, 05:57 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

Shibari
06-01-2010, 10:37 PM
it isn't on a site, it is just a local file that gets set as a start page on my mom's pc.
i shoved it out to a free hosting site but the forms won't work on there, they work fine locally. the menus are still behaving as before. they are currently set up as separate "masterdiv" but i have tried also making the entire table one masterdiv and there was no difference. i have also tried numbering them sequentially from 1 and that didn't make a difference either.

http://kinbakubi.webs.com/publictest.html