PDA

View Full Version : Cannot use a variable with Animated Collapsible DIV



b-summers
08-01-2014, 08:49 PM
1) Script Title: Animated Collapsible DIV v2.4

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

3) Describe problem: I am trying to use this "animatedcollapse.hide();" in my javascript, so get a number of div's to close during an onclick function. But for some reason this code doesn't seem to function properly when I substitute a variable.

This works fine:
animatedcollapse.hide([97, 96, 111, 107, 109, 6, 99, 7]);

But this refuses to work, and I'm not clear why?
$productIDs = 97, 96, 111, 107, 109, 6, 99, 7;
animatedcollapse.hide([$productIDs]);

I've tried saving the numbers as a string as well. But the code will only work if I manually enter the numbers in the round brackets, which I can't do because I am grabbing the numbers dynamically on another page, and saving them in a session variable. I've also tried:
.animatedcollapse.hide([<?php echo $_SESSION['product_ids']; ?>]);
which also does not work.