Jump to content

Quick toggle button question


Tensing

Recommended Posts

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

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.