Pattatharasu N Pattatharasu N - 3 months ago 9
Ajax Question

Store active list selection after reloading the page

I need to make sure the list item is selected even after the page gets refreshed. Here's the code:

<style>
li a.selected
{
color: red;
}
</style>


<ul>
<li><a href="arasu.php?something_dynamically">test</a></li>
<li><a href="arasu.php?something_dynamically">test 1</a></li>
<li><a href="arasu.php?something_dynamically">test 2</a></li>
</ul>

Answer

If I understood your question correctly, you might want to try something like that :

<ul>
  <li><a href="arasu.php?item=1" <?php if($_GET['item'] == 1):?>class="active"<?php endif;?>>test</a></li>
  <li><a href="arasu.php?item=2" <?php if($_GET['item'] == 2):?>class="active"<?php endif;?>>test 1</a></li>
  <li><a href="arasu.php?item=3" <?php if($_GET['item'] == 3):?>class="active"<?php endif;?>>test 2</a></li>
</ul>