CodeIgniter Forums
Active tab or menu - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Active tab or menu (/showthread.php?tid=68549)



Active tab or menu - kayinja.denis - 07-25-2017

why is it when i select one tab even the other gets highlighted like it is in the image attached.
I mean I've five menu/tabs;
Fee type
Expense Type
Invoice
Payment History
Expense
but when i select "Expense Type" and gets highlighted even "Expense" get highlighted the same case applies to "Expense"
I've tried to go through that problem but I've failed, any suggestion please.


RE: Active tab or menu - Martin7483 - 07-25-2017

Without any code we could only guess


RE: Active tab or menu - albertleao - 07-25-2017

If you're using ajax, you can use javascript to set a current tab to have a class.

Using php, you can use a conditional statement to check a url for a tab that needs to be highlighted. For example

Code:
<ul class="list-inline">
 <li class="<?= is_current_url(current_url()) ? 'active' : '' ?>">
    my tab one
 </li>

 <li class="<?= is_current_url(current_url()) ? 'active' : '' ?>">
    my tab two
 </li>
</ul>

You'll have to write the is_current_url() function, but that should work for you.

I would recommend using both javascript and the php method so your tabs work regardless of whether or not you're using Ajax


RE: Active tab or menu - rtenny - 07-26-2017

Maybe expense type and expense share the same tab ID.
But without any code this is pure guess work.