My collapsible list won't collapse

T

Tony Strazzeri

Apologies for the (possible) repost. Servers seem to be taking too long or
perhaps my post failed for some reason. In any case I had forgotten to add
my modified code to the post. So here it is again (with the code)

Cheers
TonyS.
-------------------------------------------------------


Hi Murray,
I found your example for collapsible outline and have managed to get it to
work for me. Thanks for posting it.

I wonder if you would be able to help me to add some additional functionality?
I am a competent programmer in general but do not have any experience in web
scripting (Javasrcipt?). I have worked out how to have one of the sections
start in expanded mode.

Now I want to modify the code do the following two things
1. I would like to scroll the page so that the newly expanded text is at the
top of the page. Is this possible?

2. I will be adding additional sections in the future. From what I see, the
selected section is expanded and each of the other sections is called at each
point to un-expand it. This makes the code rather unwieldily for large
numbers of sections/points. Is it possible to define an array with all of the
section names so that the FP_changeProp only needs to be sent the name of the
section to be expanded and have it traverse the array to un-expand all of the
others?

It seems to me that both of these features should be fairly simple but
beyond me at the moment. I hope you (or someone else) can help me with this.

---------
The function is called with:
<a href="#"
onclick="FP_changeProp(/*id*/'sub_Present',1,'style.display','block','bm_Present');
FP_changeProp(/*id*/'sub_FutureSoon',1,'style.display','none');
FP_changeProp(/*id*/'sub_FutureLong',1,'style.display','none')">

---------

The modified function is:

function FP_changeProp()
{ //v1.0
var args=arguments,d=document,i,j,id=args[0],o=FP_getObjectByID(id),s,ao,v,x;
d.$cpe=new Array();
if(o)
for(i=2; i<args.length; i+=2)
{ v=args[i+1]; s="o";
ao=args.split(".");
for(j=0; j<ao.length; j++)
{
s+="."+ao[j];
if(null==eval(s))
{
s=null; break;
}
}
x=new Object;
x.o=o;
x.n=new Array();
x.v=new Array();
x.n[x.n.length]=s; // Why is this different to below (ie not using
eval)?
eval("x.v[x.v.length]="+s); //Is this clearing the x.v array because s
is null?
d.$cpe[d.$cpe.length]=x;
if(s) eval(s+"=v");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top