PDA

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



izbaviboy
06-11-2008, 01:04 PM
1) Script Title:
Switch Content Script

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/switchcontent.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)?

ddadmin
06-11-2008, 07:19 PM
Hmm doesn't the 1st demo on the script page (http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm)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.

izbaviboy
06-12-2008, 07:43 AM
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?"!

codeexploiter
06-12-2008, 08:11 AM
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.

izbaviboy
06-12-2008, 08:29 AM
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?"!

izbaviboy
06-13-2008, 11:50 AM
Any answer?

ddadmin
06-14-2008, 09:20 AM
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"?

izbaviboy
06-14-2008, 03:23 PM
bide open = hold on or stay open :)

izbaviboy
06-14-2008, 03:37 PM
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.

ddadmin
06-15-2008, 08:15 AM
Ah ok. Sometimes a screenshot is necessary to get the point across. To do what the later screenshot shows, try replacing function:


switchcontent.prototype.toggledisplay=function(header){
"
"
}

with the below version instead:


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"
}

izbaviboy
06-17-2008, 06:14 PM
It is solutions!
Thank you ddadmin very much!