This topic is locked
[SOLVED]

 Additional WHERE tabs - Retrieve active tab id

10/27/2017 4:44:56 AM
PHPRunner General questions
chris.cleary author

When using the 'Additional WHERE tabs' feature, in phprunner9.8, i would like to obtain the active tab and then perform some actions (e.g. show/hide buttons) depending on which tab the user has clicked.

In the help file i can see the ability to addTab(), deleteTab(), setTabTitle() but i cannot see anything about retrieving the current Tab id.
Thanks

Chris

Y
YCH 10/27/2017



When using the 'Additional WHERE tabs' feature, in phprunner9.8, i would like to obtain the active tab and then perform some actions (e.g. show/hide buttons) depending on which tab the user has clicked.

In the help file i can see the ability to addTab(), deleteTab(), setTabTitle() but i cannot see anything about retrieving the current Tab id.
Thanks

Chris


For inspiration see this jsfiddle : http://jsfiddle.net/Lv5VJ/2/

Admin 10/30/2017

Here is the Javascript code that returns the ID of the active WHERE tab:

$("li[class=active]").find("a").attr("data-tabid")
chris.cleary author 11/2/2017



Here is the Javascript code that returns the ID of the active WHERE tab:

$("li[class=active]").find("a").attr("data-tabid")



I have put the following in the JavaScript OnLoad event but the alert box is displaying 'undefined'
//Get Active TAB ID

var ActiveTABID = $("li[class=active]").find("a").attr("data-tabid");

alert(ActiveTABID);

Admin 11/2/2017

Your code works here.

chris.cleary author 11/3/2017



Your code works here.



I don't understand why my code won't work.

I have reset the page and tried again, but i am still getting the 'undefined' message

Admin 11/3/2017

As an alternative you can read "tab" parameter from the URL. This article can help:

https://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-get-parameters

chris.cleary author 11/6/2017

I am using this currently to determine the current tab, but i came across a few issues with this which resulted in me asking my original question.
When a user clicks on a column to sort the records or uses the search function the url changes from

/dbo_tAppointment_Record_list.php?tab=1008

to

/dbo_tAppointment_Record_list.php?orderby=dApptDate
...and when you initially land on a page with 'Additonal WHERE tabs' there is no 'tab=????' in the url until you click on another tab and then click back.

Admin 11/6/2017

After you read tab id from the URL save it in session variable and use it in subsequent page calls till new one appears in the URL.