PDA

View Full Version : extendable content



chechu
08-31-2007, 08:15 AM
1) Script Title: combo box viewer

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/comboviewer.htm

3) Describe problem: Hey guys,
No problem, just a little change. I'd like to have the same effect (opening content on-click), but instead of from a combo box, just a textlink, so I get the following:
- affiliates
- new members
and when you click on the text, the login requirements appear under it
Thanks !

Twey
08-31-2007, 08:33 AM
It's poorly written, you'll have to modify it:
function expandone(selectedItem){
if (document.getElementById){
// remove the line that was here
contractall()
document.getElementById("dropmsg"+selectedItem).style.display="block"
}
}Then you can, e.g.:
<a href="loginrequirements.html" onclick="expandone(3); return false;">The sample text for this one is daft :-\
JavaScript is a scripting language originally developed by Netscape to add interactivity and power to web documents. It is purely client side, and runs completely on the client's browser and computer.Not necessarily true; JScript is available for scripting in ASP, and several web frameworks and even application frameworks (wxJS) have sprung up using Javascript.
Java is completely different from JavaScript- it's more powerful, more complex, and unfortunately, a lot harder to master. It belongs in the same league as C, C++, and other more complex languages. Java programs need to be compiled before they can run, while JavaScript do not.Harder to master? More complex languages? A dynamic, prototype-based language like Javascript is a lot harder to master than a simple, static, class-based language like C++ or Java, where objects get what properties they're given and like it :p C is in an entirely different league of simplicity, since it's entirely procedural -- no classes or prototypes to worry about!

chechu
08-31-2007, 12:18 PM
Don't really understand your solution, but I see that you work with an external page. Can it be done with divs in the same page ?

chechu
08-31-2007, 06:37 PM
What I am looking for, is like on this page on the right:
http://www.tradetracker.net/nl
click on affiliate, and a content (in this case a form) comes up, without changing pages.

Twey
08-31-2007, 07:31 PM
As here. The "external page" is a fallback page for users without Javascript, and is a must-have to use this script accessibly.

chechu
08-31-2007, 11:02 PM
I found this:

<style type="text/css">
.menutitle{
cursor:pointer;
margin-bottom: 5px;
background-color:white;
color:#666666;
padding:2px;
text-align:left;
}

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

<script type="text/javascript">
var persistmenu="yes"
var persisttype="sitewide"
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(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>

and


<div id="masterdiv">
<div class="menutitle" onclick="SwitchMenu('sub1')>title</div>

Any downsides with this ?