Wednesday, 15 February 2012

php - How to retain the current tab when updating a page? -



php - How to retain the current tab when updating a page? -

i have horizontal tab scheme set so:

<a id="default" class="link" href="#">tab 1</a> <a class="link" href="#">tab 2</a> <a class="link" href="#">tab 3</a>

which works using basic html , css.

i have table each can handle sorting through php causes page redirect puts new sorting type in url.

however, if in, let's say, 3rd tab, , click alter sorting type, page changes , sorting type changed goes tab 1. how can have retain tab in previously?

somehow on table uses server-side sorting, passing server information. may form

<form method="post" action="http://www.example.com/tabs.php?sorttab2=a" />

or links

<a href="http://www.example.com/tabs.php?sorttab2=a">sort</a>

either way, if add together parameter querystring called tab, can utilize php print id="default" in current tab.

<?php $activetab = isset($_request['tab']) ? $_request['tab'] : 1; ?> <a <?php if($activetab == 1) echo 'id="default" '; ?>class="link" href="#">tab 1</a> <a <?php if($activetab == 2) echo 'id="default" '; ?>class="link" href="#">tab 2</a> <a <?php if($activetab == 3) echo 'id="default" '; ?>class="link" href="#">tab 3</a>

then, within each tab, create sure specify tab query parameter you're calling php sort.

<form method="post" action="http://www.example.com/tabs.php?sorttab2=a&tab=2" /> <a href="http://www.example.com/tabs.php?sorttab2=a&tab=2">sort</a>

php html css

No comments:

Post a Comment