I use this script for expanding and collapsing my menus: http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm My question is since this: <a href="javascript:animatedcollapse.toggle('<?=$results[id]?>')"><img src="image.jpg" border="0" align="absmiddle"></a> expands/collapses the list. Would I be able to collapse and open all menus at once? $results[id] is a number from 1 to whatever the loop brings...
Yes, you will be able to do it, but for that you will have to do little modification in script. Or rather, write a javascript function, which calls collapse on all menu items which you wish to expand / collapse at once..
I'm not very good with javascript, actually I am a total noob. Could you give me a hint? I prefer going with a function.
OK, I figured something out by what I found on the demo page... <a href="javascript:animatedcollapse.show(['1', '2', '3'])">Show Examples 1, 2, 3</a> | <a href="javascript:animatedcollapse.hide(['1', '2', '3'])">Hide Examples 1, 2, 3</a></b> That collapses '1', '2' and '3' The problem here is that sometimes I might have over 50 lists. Would this method still be a smart way to do this? PHP loops generate the lists. For each list it also generates this new line: <script> animatedcollapse.addDiv('<?=$results[id]?>', 'fade=1', 'hide=1') </script> <a href="javascript:animatedcollapse.toggle('<?=$results[id]?>')"><img src="image.jpg" border="0" align="absmiddle"></a> Which means that <script> animatedcollapse.addDiv('<?=$results[id]?>', 'fade=1', 'hide=1') </script> is needed for each list. Would it be possible to skip the <script> animatedcollapse.addDiv('<?=$results[id]?>', 'fade=1', 'hide=1') </script> line or make just one line so one size fits all? And then use the animatedcollapse.show/hide function to collapse open all of them?
Yeah, that should do the work. The script already has provision to expand / collapse multiple div at a time. Well, with 50 divs I would suggest, you write a javascript function, which will call expande / collapse on each div in loop. Give it a try on simple html first, and then you can integrate it in your application / website.
I tried and I failed. I've created another loop in php to collect the ids and pass it to js. I tried to do in javascript too but it did not work. Can you keep adding values to a variable like in php? lala .= ""+ numb + ""; numb is what the loop brings