Strangeplant
10-10-2014, 07:39 PM
Hi,
I'm using switchtoggle.js, found at http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm (the older version, but it won't make any difference here).
Works beautifully, BTW, and am using it in several places, usually generating the sections in a loop from content taken from a database or flat files with php, so the sections have an base id of 'band' and numbered 1, 2, 3..... with the resultant id's being band1, band2, etc.
I need to know which section is expanded so I can have javascript do appropriate tasks depending on which section is expanded. So, to do this I need to augment the script. Where and how are somewhat evasive, but it probably should be in this section:
switchcontent.prototype.expandcontent=function(header){
var innercontent=document.getElementById(header.id.replace("-title", ""))
innercontent.style.display="block"
this.togglestatus(header, this.statusOpen)
this.togglecolor(header, this.colorOpen)
}
Has anyone already done this? I was thinking about adding:
var sec=document.getElementByID(header);
section=sec.substring(str.lastIndexOf("d")+1,str.lastIndexOf("-"));
and defining section in the first, main javascript in my program. The "d" is the last character in the base section identifier that I happen to be using in this page, but it is not a generic solution. And also, this is not the right way because variables should be self contained in this file and not referenced directly elsewhere. What is the proper way to do this so I have generic code to use elsewhere?
I'm using switchtoggle.js, found at http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm (the older version, but it won't make any difference here).
Works beautifully, BTW, and am using it in several places, usually generating the sections in a loop from content taken from a database or flat files with php, so the sections have an base id of 'band' and numbered 1, 2, 3..... with the resultant id's being band1, band2, etc.
I need to know which section is expanded so I can have javascript do appropriate tasks depending on which section is expanded. So, to do this I need to augment the script. Where and how are somewhat evasive, but it probably should be in this section:
switchcontent.prototype.expandcontent=function(header){
var innercontent=document.getElementById(header.id.replace("-title", ""))
innercontent.style.display="block"
this.togglestatus(header, this.statusOpen)
this.togglecolor(header, this.colorOpen)
}
Has anyone already done this? I was thinking about adding:
var sec=document.getElementByID(header);
section=sec.substring(str.lastIndexOf("d")+1,str.lastIndexOf("-"));
and defining section in the first, main javascript in my program. The "d" is the last character in the base section identifier that I happen to be using in this page, but it is not a generic solution. And also, this is not the right way because variables should be self contained in this file and not referenced directly elsewhere. What is the proper way to do this so I have generic code to use elsewhere?