jQuery collapsible divs

Shadow121

Member
Messages
901
Reaction score
0
Points
16
I've posted this elsewhere but I got no help >.>;

I have a system for it set-up on my site and it works fine on the main page but when I go to like /members/ or /ucp/ it stops working and reverts to the old images that were used. Any help? and Yes I've changed them.

Or not...?
PHP:
<?php
header("Content-Type: application/javascript; charset=UTF-8");
require("../configuration.db.php");
?>
$(document).ready(function() {
<?php
foreach($_SESSION as $key => $value){
?>
//alert('<?=$key?>: <?=$value?>');
<?
if($value == 'Disabled'){
?>
$("#<?=$key?>").toggle();
document.<?=$key?>_Click.src = '<?=SITE_LINK?>img/Icons/show.png';
<?php
}else{
?>
$("#<?=$key?>").toggle();
document.<?=$key?>_Click.src = '<?=SITE_LINK?>img/Icons/hide.png';
<?php
}
}
?>
<?php
    $getBlocks = $db->dbQuery("SELECT * FROM `".DB_PREFIX."blocks` WHERE `side` = 'left' OR `side` = 'right';");
    while($getBlks = $db->dbFetch($getBlocks)){
?>
$("#<?=$Functions->replaceSpaces($getBlks->title)?>_Click").click(function() {
$("#<?=$Functions->replaceSpaces($getBlks->title)?>").slideToggle("normal");
if(document.<?=$Functions->replaceSpaces($getBlks->title)?>_Click.src == '<?=SITE_LINK?>img/Icons/show.png'){
    document.<?=$Functions->replaceSpaces($getBlks->title)?>_Click.src = '<?=SITE_LINK?>img/Icons/hide.png';
    <?php
    $_SESSION[$Functions->replaceSpaces($getBlks->title)] = "Enabled";
    ?>
}else{
    document.<?=$Functions->replaceSpaces($getBlks->title)?>_Click.src = '<?=SITE_LINK?>img/Icons/show.png';
    <?php
    $_SESSION[$Functions->replaceSpaces($getBlks->title)] = "Disabled";
    ?>
}
});
<?php
}
?>
/*
REGULAR CONTENT FRONT PAGE
*/
$("#Greetings_Content_Click").click(function() {
$("#Greetings_Content").slideToggle("normal");
if(document.Greetings_Content_Click.src == '<?=SITE_LINK?>img/Icons/show.png'){
    document.Greetings_Content_Click.src = '<?=SITE_LINK?>img/Icons/hide.png';
    <?php
    $_SESSION['Greetings_Content'] = "Enabled";
    ?>
}else{
    document.Greetings_Content_Click.src = '<?=SITE_LINK?>img/Icons/show.png';
    <?php
    $_SESSION['Greetings_Content'] = "Disabled";
    ?>
}
});
$("#Whats_In_Store_Click").click(function() {
$("#Whats_In_Store").slideToggle("normal");
if(document.Whats_In_Store_Click.src == '<?=SITE_LINK?>img/Icons/show.png'){
    document.Whats_In_Store_Click.src = '<?=SITE_LINK?>img/Icons/hide.png';
    <?php
    $_SESSION['Whats_In_Store'] = "Enabled";
    ?>
}else{
    document.Whats_In_Store_Click.src = '<?=SITE_LINK?>img/Icons/show.png';
    <?php
    $_SESSION['Whats_In_Store'] = "Disabled";
    ?>
}
});
});

That is my code. ._. Its working on /home/ and / but no where else.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
In your post, it's not at all clear what's going wrong, what you've done to try to fix it and what the code is supposed to do. Read "How To Ask Questions The Smart Way".

I've posted this elsewhere but I got no help >.>;

I have a system for it set-up on my site and it works fine
What works fine? Based on what you say next, I assume you mean you're getting the images you want. If this is the case and the problem is that you're seeing the wrong images on some pages, then your post title ("jQuery collapsible divs") is misleading & immaterial.

on the main page but when I go to like /members/ or /ucp/ it stops working and reverts to the old images that were used. Any help? and Yes I've changed them.
Changed what?

Or not...?
Does "Or not...?" mean you're not sure you "change them"?

When you post code, post a minimal test case. This means it includes all necessary lines but no more. It should be complete & concise.

PHP:
...
document.<?=$key?>_Click.src = '<?=SITE_LINK?>img/Icons/show.png';
...
Is "SITE_LINK" a defined constant? What's its value?
 

Shadow121

Member
Messages
901
Reaction score
0
Points
16
How about I don't take a look at that link.

"or not" I forgot to remove when I was editing the previous post and it was working with cookies. But I swapped it over to sessions.

SITE_LINK is defined in configuration.db.php

"Changed what"? I changed over the image links and such things so that it would not revert to the old ones but still manages to go back to them for no reason.

and works fine as in it expands / collapses but it screws up when going to a different area of the website.
 
Last edited:
Top