Results 1 to 6 of 6

Thread: extendable content

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    920
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default extendable content

    1) Script Title: combo box viewer

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...omboviewer.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 !

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's poorly written, you'll have to modify it:
    Code:
    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.:
    Code:
    <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 C is in an entirely different league of simplicity, since it's entirely procedural -- no classes or prototypes to worry about!
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    920
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    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 ?

  4. #4
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    920
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    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.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    As here. The "external page" is a fallback page for users without Javascript, and is a must-have to use this script accessibly.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    920
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    I found this:
    Code:
    <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

    Code:
    <div id="masterdiv">
    <div class="menutitle" onclick="SwitchMenu('sub1')>title</div>
    Any downsides with this ?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •