PDA

View Full Version : Text Switch Menu



F32
18-01-2007, 08:18 PM
Is is possible to use a switch menu, but instead of using images, you can use text?

Edited by Lµke (Forum Moderator): Thread Moved from Website Designing. Please post in the correct section next time, Thanks :).

Recursion
18-01-2007, 09:24 PM
Yes. Just change the image tags into text tags...

Mentor
18-01-2007, 09:26 PM
Dont all switch menu's use text anyway o.0

F32
18-01-2007, 09:27 PM
I don't get what you're saying.


<img src="img.PNG" onclick="SwitchMenu('sub1')" width="129" height="17">
<span class="submenu" id="sub1"><font size="1" face="Verdana">

Change to what?

Recursion
18-01-2007, 09:28 PM
Take out the image code and add a text tag (i dunno???) instead...

If that isnt right i cannot remember but i did it once in dreamweaver using the one of DD, there is a text based one on there somewhere?

F32
18-01-2007, 09:31 PM
Dreamweavers Auto-Coding sucks.

Ini
18-01-2007, 09:40 PM
Use this code:




<head>
<style type="text/css">
.menutitle{
cursor:pointer;
margin-bottom: 5px;
background-color:#ffffff;
color:#000000;
width:140px;
padding:2px;
font-style:verdana;
text-align:left;
font-weight:bold;
/*/*/border:0px solid #000000;/* */
}

.submenu{
margin-bottom: 0.5em;
}
</style>

<script type="text/javascript">

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

if (document.getElementById){
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");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu")
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(off set, 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>
</head>
<body>
<font face="Verdana" size="1" color="000000">
<!-- Keep all menus within masterdiv-->
</font>
<div id="masterdiv">

<div class="menutitle" onclick="SwitchMenu('sub1')">
<font face="Verdana" size="1">Link</font></div>
<font face="Verdana" size="1">
<span class="submenu" id="sub1">
- <a href="#"><span style="text-decoration: none">1</span></a><br>
- <a href="#"><span style="text-decoration: none">2</span></a><br>
- <a href="#"><span style="text-decoration: none">3</span></a><br>
- <a href="#"><span style="text-decoration: none">4</span></a>
</span>

</font>

<div class="menutitle" onclick="SwitchMenu('sub2')">
<font face="Verdana" size="1">Link</font></div>
<font face="Verdana" size="1">
<span class="submenu" id="sub2">
- <a href="#"><span style="text-decoration: none">1</span></a><br>
- <a href="#"><span style="text-decoration: none">2</span></a><br>
- <a href="#"><span style="text-decoration: none">3</span></a><br>
- <a href="#"><span style="text-decoration: none">4</span></a>
</span>

</font>

<div class="menutitle" onclick="SwitchMenu('sub3')">
<font face="Verdana" size="1">Link</font></div>
<font face="Verdana" size="1">
<span class="submenu" id="sub3">
- <a href="#"><span style="text-decoration: none">1</span></a><br>
- <a href="#"><span style="text-decoration: none">2</span></a><br>
- <a href="#"><span style="text-decoration: none">3</span></a><br>
- <a href="#"><span style="text-decoration: none">4</span></a>
</span>

</font>

<div class="menutitle" onclick="SwitchMenu('sub4')">
<font face="Verdana" size="1">Link</font></div>
<font face="Verdana" size="1">
<span class="submenu" id="sub4">
- <a href="#"><span style="text-decoration: none">1</span></a><br>
- <a href="#"><span style="text-decoration: none">2</span></a><br>
- <a href="#"><span style="text-decoration: none">3</span></a><br>
- <a href="#"><span style="text-decoration: none">4</span></a>
</span>
</font>
</div>
</body>

Mentor
18-01-2007, 09:41 PM
What script are you useing? (post the whole lot)

It would make it signifcantly easyer to tell you what needs to be changed o.0

Recursion
18-01-2007, 09:43 PM
I think Cняιѕ was right...

It looks familiar.

F32
18-01-2007, 09:49 PM
Ahhh,

I'll try that, that's just taken out the image and inserted font tags.

Worked a treat, thanks Chris.

Common Sense really.

Mentor
18-01-2007, 09:49 PM
I think Cняιѕ was right...

It looks familiar.

It should do, its the standard switch menu script provided by Dynamic drive (they added the save state functionality which wasn't included with the original script)

Ini
18-01-2007, 09:54 PM
yes lol got script from dynamic drive.

yw ad

F32
18-01-2007, 10:00 PM
Hmm, I got another problem now.

lol.

God I suck.

http://www.adzat.londonki.speed-networks.org/SkyHabbo/

The 'EXTRAS' bit stays open when you click another one, when it shouldn't.

Ini
18-01-2007, 10:02 PM
post the extras part

F32
18-01-2007, 10:03 PM
<div class="menutitle style1" onclick="SwitchMenu('sub6')"><strong>
<font face="Verdana">EXTRAS</font></strong></div>
<font face="Verdana" size="1">
<span class="submenu" id="sub6">
- <a href="#"><span style="text-decoration: none">1</span></a><br>
- <a href="#"><span style="text-decoration: none">2</span></a><br>
- <a href="#"><span style="text-decoration: none">3</span></a><br>
- <a href="#"><span style="text-decoration: none">4</span></a>
</span>
</font>
</div>

Ini
18-01-2007, 10:06 PM
try:



<div class="menutitle" onclick="SwitchMenu('sub6')"><strong>
<font face="Verdana">EXTRAS</font></strong></div>
<font face="Verdana" size="1">
<span class="submenu" id="sub6">
- <a href="#"><span style="text-decoration: none">1</span></a><br>
- <a href="#"><span style="text-decoration: none">2</span></a><br>
- <a href="#"><span style="text-decoration: none">3</span></a><br>
- <a href="#"><span style="text-decoration: none">4</span></a>
</span>
</font>
</div>

F32
18-01-2007, 10:08 PM
Nope, didn't work :(

Ini
18-01-2007, 10:11 PM
hmm.. ill take another look now

Ini
18-01-2007, 10:19 PM
got it lol.

go to switch 5

at the end just before you start 6 and remove the -




</div>

tag



Then start sub 6

Want to hide these adverts? Register an account for free!