Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Switch Content Script - open only one content after Expand All and click on one...

  1. #1
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Switch Content Script - open only one content after Expand All and click on one...

    1) Script Title:
    Switch Content Script

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    3) Describe problem:
    Now after Expand All and click on one content header (bobcontent1-title) I close this content. How I can get only one open content (bobcontent1) after Expand All and click on one content header (bobcontent1-title)?

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm doesn't the 1st demo on the script page already behave like this? That is, even after clicking on "Expand All", manually clicking on each header afterwards still means that only one header is open at any time as the script closes the previously opened one. Or perhaps I'm not understanding your question.

  3. #3
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    After clicking on "Expand All" in Demo 1 you have:

    What is JavaScript?
    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.

    Difference betwen Java & JavaScript?
    Java is completely different from JavaScript. The former is a compiled language while the later is a scripting language.

    What is DHTML?
    DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML. Through them a new level of interactivity is possible for the end user experience.


    But after this action and click on "What is JavaScript?" (for example) I need to close other content ("Difference betwen Java & JavaScript?" and "What is DHTML?") and bide open content "What is JavaScript?"!

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Yes ddadmin is right check the first demo in the demo page which behaves exactly the way you want. In other words only one item can be expanded at a time.

  5. #5
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by codeexploiter View Post
    In other words only one item can be expanded at a time.
    This is true if you have "Contract All" content - only one item can be expanded at a time.

    But when you click on "Expand All" and AFTER click on one content header ("What is JavaScript?" for example) then you close this content and bide open other content. I need reverse situation. I need to close other content ("Difference betwen Java & JavaScript?" and "What is DHTML?") and bide open content "What is JavaScript?"!

  6. #6
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Any answer?

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm you're going to have to elaborate. Your last post still confuses me actually You say:

    I need to close other content ("Difference betwen Java & JavaScript?" and "What is DHTML?") and bide open content "What is JavaScript?"!
    What do you mean by "bide open"?

  8. #8
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    bide open = hold on or stay open

  9. #9
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    When you clicking on "Expand All" and AFTER click on one content header ("What is JavaScript?" for example) you have situation in attachment file demo1_now.jpg. I need solution in attachment file demo1_need.gif.

  10. #10
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Ah ok. Sometimes a screenshot is necessary to get the point across. To do what the later screenshot shows, try replacing function:

    Code:
    switchcontent.prototype.toggledisplay=function(header){
    "
    "
    }
    with the below version instead:

    Code:
    switchcontent.prototype.toggledisplay=function(header){
    	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content container for this header
    	this.sweepToggle("contract")
    		this.expandcontent(header)
    	if (this.collapsePrev)
    		this.prevHeader=header //Set current expanded content as the next "Previous Content"
    }

  11. The Following User Says Thank You to ddadmin For This Useful Post:

    izbaviboy (06-17-2008)

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
  •