Tensing Posted June 26, 2009 Share Posted June 26, 2009 So I've got this code... but every time users load the page the toggle buttons are opened, and I'd like them to be closed, and if they wish to open them, they can just click them. I'd really appreciate it if someone gives me a hand with this I'm kindda new to php. <div id="Community"> <?php if (file_exists('community.xml')){ $XML = simplexml_load_file('community.xml'); if ($XML === false) throw new Exception('Malformed XML'); }else{die('Unable to load community.xml');} foreach ($XML->category as $cat){ echo '<div class="button" onclick="menu_toggle(this)" style="cursor: pointer;">'.$cat['name'].'</div><ul>'."\n"; foreach ($cat->item as $item) echo '<li><a href="'.$item['href'].'">'.$item.'</a></li>'."\n"; } ?> </div> Link to comment https://forums.phpfreaks.com/topic/163739-quick-toggle-button-question/ Share on other sites More sharing options...
dzelenika Posted June 26, 2009 Share Posted June 26, 2009 So I've got this code... but every time users load the page the toggle buttons are opened, and I'd like them to be closed, and if they wish to open them, they can just click them. I'd really appreciate it if someone gives me a hand with this I'm kinda new to php. <div id="Community"> <?php if (file_exists('community.xml')){ $XML = simplexml_load_file('community.xml'); if ($XML === false) throw new Exception('Malformed XML'); }else{die('Unable to load community.xml');} foreach ($XML->category as $cat){ echo '<div class="button" onclick="menu_toggle(this)" style="cursor: pointer;">'.$cat['name'].'</div><ul>'."\n"; foreach ($cat->item as $item) echo '<li><a href="'.$item['href'].'">'.$item.'</a></li>'."\n"; } ?> </div> I don't see that You are closed <ul> tag? Link to comment https://forums.phpfreaks.com/topic/163739-quick-toggle-button-question/#findComment-863977 Share on other sites More sharing options...
Tensing Posted June 26, 2009 Author Share Posted June 26, 2009 nope, I checked the tag and it has nothing to do with being closed when the page loads :-\ Link to comment https://forums.phpfreaks.com/topic/163739-quick-toggle-button-question/#findComment-863981 Share on other sites More sharing options...
dzelenika Posted June 26, 2009 Share Posted June 26, 2009 How do you have formatted class button. what is your function menu_toggle(this) code? Link to comment https://forums.phpfreaks.com/topic/163739-quick-toggle-button-question/#findComment-863984 Share on other sites More sharing options...
Tensing Posted June 27, 2009 Author Share Posted June 27, 2009 I looked for the function but I couldn't find it (this was made by someone else and I'm just editing it) If you need any other information, I can try to find it. *button is a class from the ccs (just a picture and margins) *li is also just a tag from the ccs and the code inside community.xml: <?xml version="1.0" encoding="utf-8"?> <community> <category name="Community"> <item href="ranks.php?sort=level">Highscores</item> <item href="characters.php">Characters</item> <item href="houses.php">Houses</item> <item href="guilds.php">Guilds</item> <item href="bans.php">Bans</item> </category> </community> If anyone has any alternate options, I'll glady take them up Tnx guys Link to comment https://forums.phpfreaks.com/topic/163739-quick-toggle-button-question/#findComment-864576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.