Results 1 to 5 of 5

Thread: OnLoad Switch Content Script II

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

    Default OnLoad Switch Content Script II

    1) Script Title: DD Switch Content Script II

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

    3) Describe problem: I am using this script in a dynamic way with asp and a SQL query so the content appears on demand, for example, I have a list of movie titles and the showtimes are hidden, I would like to expand one specific movie depending on the user preference.

    So I was reading in the threads and I found one that talk about this issue posted by spyr (07-03-2005, 03:08 PM) where he was trying to use this:

    <body onLoad="expandcontent(this, 'sc1')">

    but it did not work, and right after this he quoted: Never mind! Sorry to waste everyone's time but stupid me just found the answer.

    I have played with this idea for ours but it seems that I am more stupid than spyr and cannot find the answer. Can someone please help I will appreciate it very much.

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

    Default

    Hmm that thread really isn't relevant anymore, as the script has long been rewritten. Can you describe in more detail what you're trying to accomplish?

  3. #3
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I can show you an example

    when the user goes to a detail movie page I show a list of movies that are playing in certain theater with the showtimes hidden and I want to expand the showtimes of the selected movie.

    You can see an example here:

    http://www.eg.com.mx/g2/cine/AjaxTab...&complejoID=45

    In this page you can see we are showing the movie shrek the third and I want to have the shrek the third showtimes expanded in the theater movie list on the right, since it is a dynamic list and you can change the theater the movie is not always in the same position, in this case the third position and I cannot use the defaultExpanded(2) because if you change the theater it will probably be in other position.

    What I want to do is to open the content using the ID something like <body onLoad="expandcontent(this, 'movie3')"> but obviously this does not work.

    I got the idea from one comment from spyr in the thread http://www.dynamicdrive.com/forums/showthread.php?t=48 where he had a similar problem and solve it but did not post the answer.

    any ideas? or can you please point me to the new version of the script?

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

    Default

    No, you do have the new version of the script installed. I was referring to Spyr's post, which is based on the old version, and isn't applicable here even if a solution was mentioned.

    If I understood your question correctly then, what you're basically trying to do is to be able to expand a content on demand based on the ID of the content. Add the below code to the end of switchicon.js:

    Code:
    //PUBLIC: Expands a content based on its ID entered
    
    switchicon.prototype.userexpand=function(id){
    	var header=document.getElementById(id+"-title")
    	var innercontent=document.getElementById(id)
    	innercontent.style.display="block"
    	if (this.collapsePrev && typeof this.prevHeader!="undefined" && this.prevHeader.id!=header.id) // If "Collapse Previous" is enabled and there's a previous open content
    		this.contractcontent(this.prevHeader) //Contract that content first
    	if (this.collapsePrev)
    		this.prevHeader=header //Set current expanded content as the next "Previous Content"
    	header.innerHTML=this.openHTML
    	header=null
    }
    Then, in your HTML page, you can call userexpand() as you wish to expand a particular content on demand. For example:

    Code:
    var faq=new switchicon("icongroup1", "div") //Limit scanning of switch contents to just "div" elements
    faq.setHeader('<img src="minus.gif" />', '<img src="plus.gif" />') //set icon HTML
    faq.collapsePrevious(true) //Allow only 1 content open at any time
    faq.setPersist(false) //No persistence enabled
    //faq.defaultExpanded(0) //Set 1st content to be expanded by default
    faq.init()
    
    window.onload=function(){
    faq.userexpand("faq3")
    }
    The code in red is new, and will expand the content "faq3" when the page fully loads.

  5. #5
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you ddadmin this did the trick and you took a head ache away.

    Thanks very much

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
  •