Advanced Search

Results 1 to 5 of 5

Thread: Animated Collapsible DIV v2.4 cant use variable as anchor

  1. #1
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Animated Collapsible DIV v2.4 cant use variable as anchor

    1) Script Title: Animated Collapsible DIV v2.4

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...edcollapse.htm

    3) Describe problem: i have php variable {featured.ID} it generate number for each of my items 1 2 3 etc

    so i tried in java setting it up as
    Code:
    animatedcollapse.addDiv('item{featured.ID}','speed=1,fade=0,persist=0,hide=1')
    and in div as
    Code:
    "javascript:animatedcollapse.toggle('item{featured.ID}')"></a> <a href="javascript:animatedcollapse.hide('item{featured.ID}')"></a></span></a></span>
    			<div id="item{featured.ID}" style="display:none;" class="infobox">
    then when click my link it says item1 and item2 for my two items but they only expand if i call the java for 'item1' and 'item2' instead of 'item{featured.ID}' as there will be hundreds if items i cant just call them item1 item2 item3 etc need the script to use my variable.

    btw great code im also using it here http://dahlsvarehus.dk you can see it in the ? mark icon in user login and in the icons in news and in the currency calculator section
    the places it is not work is the eye icons i have set one of the eyes to work by make code called ´item2´ just for testing
    Last edited by Dahls; 06-28-2013 at 03:07 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,709
    Thanks
    43
    Thanked 3,134 Times in 3,098 Posts
    Blog Entries
    12

    Default

    That's not valid PHP code unless the entire string is in double quotes, and even if it is it would have to be being written server side, and featured.ID would have to be defined. If it's not double quoted and written by the server, it would have to be something like:

    Code:
    animatedcollapse.addDiv('item<php echo featured.ID; ?>','speed=1,fade=0,persist=0,hide=1')
    In other words, you haven't shown enough of the PHP code for me to tell. I'm not seeing any error notices in the served source code though. But you might have them turned off. Or feastured.ID may be resolving to a blank string.

    What I do see is:

    Code:
    <script type="text/javascript">
    animatedcollapse.addDiv('jason', 'fade=1,height=80px')
    animatedcollapse.addDiv('kelly', 'fade=1,height=100px')
    animatedcollapse.addDiv('shownews','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('showforgot','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('showcurrency','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('item','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('item2','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('cat', 'fade=0,speed=400,group=pets')
    animatedcollapse.addDiv('dog', 'fade=0,speed=400,group=pets,persist=1,hide=1')
    animatedcollapse.addDiv('rabbit', 'fade=0,speed=400,group=pets,hide=1')
    animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
    	//$: Access to jQuery
    	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
    	//state: "block" or "none", depending on state
    }
    animatedcollapse.init()
    </script>
    So, if that's (the highlighted line) where you have:

    Code:
    animatedcollapse.addDiv('item{featured.ID}','speed=1,fade=0,persist=0,hide=1')
    it's not resolving on the server side.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    here is my featured id code
    Code:
    // get featured items
    $query = "SELECT id, title, current_bid, pict_url, ends, num_bids, minimum_bid, bn_only, description, shipping_cost, shipping_terms, buy_now
            FROM " . $DBPrefix . "auctions
            WHERE closed = 0 AND suspended = 0 AND starts <= " . $NOW . "
            AND featured = 'y'
            ORDER BY RAND() DESC LIMIT 12";
    $res = mysql_query($query);
    $system->check_mysql($res, $query, __LINE__, __FILE__);
    
    $i = 0;
    while($row = mysql_fetch_assoc($res))
    {
        $ends = $row['ends'];
        $difference = $ends - time();
        if ($difference > 0)
        {
            $ends_string = FormatTimeLeft($difference);
        }
        else
        {
            $ends_string = $MSG['911'];
        }   
        if ($row['buy_now'] > 0 && $row['bn_only'] == 'n' && ($row['num_bids'] == 0 || ($row['reserve_price'] > 0 && $row['current_bid'] < $row['reserve_price'])))
    {
    $row['buy_now'] = ' ' . $system->print_money($row['buy_now']) . '';
    }
    elseif ($row['buy_now'] > 0 && $row['bn_only'] == 'y')
    {
    
    }
    else
    {
    
    $row['buy_now'] = '';
    }
    $high_bid = ($row['num_bids'] == 0) ? $row['minimum_bid'] : $row['current_bid'];
        $template->assign_block_vars('featured', array(
    			'AUCTION_DESCRIPTION' => $row['description'],
    			'SHIPPING_COST' => $row['shipping_cost'],
    			'SHIPPING_TERMS' => $row['shipping_terms'],
                'ENDS' => $ends_string,
    			'DIFFERENCE'=> $difference,
                'BUY_NOW' => ($row['buy_now'] == 'y'),
                'ID' => $row['id'],
                'BID' => $system->print_money($high_bid),
                'BUY_NOW' => ($difference < 0) ? '' : $row['buy_now'],
                'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&amp;fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] : 'images/email_alerts/default_item_img.jpg',
                'TITLE' => $row['title']
                ));
    }

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,709
    Thanks
    43
    Thanked 3,134 Times in 3,098 Posts
    Blog Entries
    12

    Default

    I don't see any:

    Code:
    animatedcollapse.addDiv
    in there. And I don't know enough about PHP and mysql to really follow what you have there. I'm pretty good at PHP, it's mysql that I'm unfamiliar with.

    But it looks like feadured.ID is somehow a property of $template, so to get it, you might have to reference it as a property of $template. But, as I say I'm not all that familiar with the mysql part of the code. I do know that featured.ID, however it's accessed, must be defined as expected at the time you tell the server to write it. And that the way you tell the server to write it into the animatedcollapse.addDiv function must be valid PHP, and happen at a point on the page where it will fit into the javascript code in the required spot.

    The good news is that this:

    Code:
    <script type="text/javascript">
    animatedcollapse.addDiv('jason', 'fade=1,height=80px')
    animatedcollapse.addDiv('kelly', 'fade=1,height=100px')
    animatedcollapse.addDiv('shownews','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('showforgot','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('showcurrency','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('item','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('item2','speed=1,fade=0,persist=0,hide=1')
    animatedcollapse.addDiv('cat', 'fade=0,speed=400,group=pets')
    animatedcollapse.addDiv('dog', 'fade=0,speed=400,group=pets,persist=1,hide=1')
    animatedcollapse.addDiv('rabbit', 'fade=0,speed=400,group=pets,hide=1')
    animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
    	//$: Access to jQuery
    	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
    	//state: "block" or "none", depending on state
    }
    animatedcollapse.init()
    </script>
    Can go almost anywhere on the page after the main collapsible script. And that instead of one big block of them you can have separate:

    Code:
    <script type="text/javascript">
    animatedcollapse.addDiv('item<php echo featured.ID; ?>','speed=1,fade=0,persist=0,hide=1')
    </script>
    throughout the page as long as at the end of the page you do (right before the closing </body> tag):

    Code:
    <script type="text/javascript">
    animatedcollapse.init()
    </script>
    Sorry I cannot be of more help.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2013
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    you pointed me in the right direction, moving the script was the solution, after i placed it inside the <!-- BEGIN featured --> it was solved

    <!-- BEGIN featured -->
    <script type="text/javascript">
    animatedcollapse.addDiv('item{featured.ID}','speed=1,fade=0,persist=0,hide=1')
    </script>

    rest of my code ....
    <!-- END featured -->

    Thank you mate
    Last edited by Dahls; 06-28-2013 at 04:37 PM.

Similar Threads

  1. Animated Collapsible DIV - variable height
    By ILikeBread in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 08-02-2010, 08:42 AM
  2. Accept variable to define anchor point?
    By ARCLite Studio in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 07-20-2010, 03:22 PM
  3. Animated Collapsible DIV
    By HopeNiao in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 04-03-2008, 01:28 AM
  4. Animated Collapsible Div and animated gifs
    By flangeway in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 01-22-2008, 02:57 AM
  5. Animated Collapsible DIV - Collapsible DIVs inside collapsible DIV
    By ekin in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 09-26-2007, 02:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •