PDA

View Full Version : Layout help



Craig
20-03-2006, 05:26 PM
Right sorry if I sound like I'm being a n00b but here it is. You know on some layouts on websites on the nav you have like say for example 'Entertainment' then you click on it and a drop down menu of say 'Games' 'Music' comes on. Right well I have a layout already coded in expandable tables and was wondering how//if I could add these 'dropdowns' seeing as I don't have any yet on my template. Sorry its confusing. +Rep for help:)

Craig

nets
20-03-2006, 05:31 PM
I made one and posted it ages ago for someone, let me find it.
Edit:
Can't find it. Anyway, it's JavaScript and you just need to add an onClick atribute.

Something like:

<a href="#" onClick="document.getElementById('blah').style.display='blo ck'">Link</a>
<div id="blah" style="display:none">
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
</div>

Craig
20-03-2006, 05:33 PM
Thanks =]

Tomm
20-03-2006, 05:35 PM
Lol you pmed me about this. Where on my site do I have javascript naviagation?

---MAD---
20-03-2006, 05:36 PM
you can also search on google.co.uk for drop down menus and youll find some there :).

Craig
20-03-2006, 05:38 PM
I thought you did Tom.

Thanks Nets and Mad:)

Would this be it by anychance?



<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="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){ //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").getElementsBy TagName("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(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>

<!-- Keep all menus within masterdiv-->
<div id="masterdiv">
<font face="Verdana" size="1" color="#000000">



<div class="menutitle" onclick="SwitchMenu('sub2')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub2">
- LINK<br>
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LNIK<br>
</span>





<div class="menutitle" onclick="SwitchMenu('sub3')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub3">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>






<div class="menutitle" onclick="SwitchMenu('sub4')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub4">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>






<div class="menutitle" onclick="SwitchMenu('sub5')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub5">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>






<div class="menutitle" onclick="SwitchMenu('sub6')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub6">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>






<div class="menutitle" onclick="SwitchMenu('sub7')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub7">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>





<div class="menutitle" onclick="SwitchMenu('sub8')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub8">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>



<div class="menutitle" onclick="SwitchMenu('sub9')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub9">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>




<div class="menutitle" onclick="SwitchMenu('sub10')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub10">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>


<div class="menutitle" onclick="SwitchMenu('sub11')"><img src="THE THING YOU CLIKC ON"></div>
<span class="submenu" id="sub11">
- LINK<br>
- LINK<br>
- LINK<br>
- LNIK<br>
- LINK<br>
</span>

</div>

Tomm
20-03-2006, 05:43 PM
Looks like one.

nets
20-03-2006, 05:47 PM
That's taking it a bit too far, it only needs a simple script.

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