Jump to content

Recommended Posts

hi guys,

I am using a menu on my site that uses html (unordered list - <ul>)
and javascript to make it dynamically unfold and fold up.

I am using a PHP include file (I've called menu.php) so that i do not have to re-edit the menu manually on each page every time i decide to add or change a menu item.

However, in the html porton of the code I need to insert an id tag (i have named "original") to identify which sub item sits open on a particular page eg. on offtravel.html, on the unordered list needs to look like this in the html;

<li id="original"><a href="../en/offtravel.html">Travel insurance</a></li>

so currently there are about 30 pages, 29 <li> tags and 1 <li id ="original"> tag, which needs to move up and down the code depending on which page is live.

given that I need this tag to appear in a different <li> on each page within its appropriate <li> tag, how can I write the include menu.php to perform this task for each page as it loads so that the correct level of menu sits open?


Here is the first portion of the html code that I have pulled into the include file.
<ul>
<li><a href="#">Financial Controlling</a>
<ul>
<li><a href="#">Cash controlling</a>
<ul>
<li id="original"><a href="../en/budfor.html">Budgets and Forecasts</a></li>
<li><a href="../en/monper.html">Monitoring performance</a></li>
<li><a href="../en/restru.html">Restructuring</a></li>
</ul>
</li>
<li><a href="#">Other controls</a>
<ul>
<li><a href="../en/finind.html">Financial indicators</a></li>
<li><a href="../en/nonfin.html">Non Financial</a></li>
<li><a href="../en/marper.html">Market performance</a></li>
</ul>
</li>
</ul>
</li>
</ul>


Thanks
Link to comment
https://forums.phpfreaks.com/topic/10168-unordered-list-using-php-and-javascript/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.