SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Navigation/passing variables issue

    I have an application where all the forms are on popups and many of the forms use tabbed interfaces. Let's say I have a popup form that has 4 tabs. Sometimes when you land on that form, all 4 tabs should work. At other times, various ones need to be deactivated, with a javascript alert telling the user they can't access that part of the form yet. Also, the tab you land on can vary. So sometimes, you might land on the form with tab 2 being on top, other times tab 4 might be on top, etc. So what I need is a way to specify both which tab is on top and whether each of the other 3 tabs is active or deactivated. I've got a solution for the "which tab is on top" part - what I'm looking for here is help with how to specify which tabs should be active and which inactive. So far I have URLs that are like this sample:

    PHP Code:
    <a href="javascript:newWin('popups.php?popupContent=addClient&openTab=insur');" title="Add Client"><img src="<?php echo URL;?>_images/addIcon.gif" alt="Add Client" /></a>
    popups.php?popupContent=addClient&openTab=insur gets these 2 cases from popups.php. popupContent tells which form to display, openTab tells which tab on that form to put on top:

    PHP Code:
    switch ($_GET['popupContent']) {
        case 
    "addClient":
            
    $title 'Add a New Client';
            include_once(
    TEMPLATE_DIR."addClient.tpl.php"); 
            break;
    ... }

    switch(
    $_GET['openTab']){
              case
    'insur':
              echo
    "<script type='text/javascript'>switchTabs('".$_GET['openTab']."', 'tabAddClient2');</script>";
              break; 
    Once you get to addClient.tpl.php, the basic code for a tabbed section is like this:

    PHP Code:
        <ul class="tabsetTabs">
           <
    li><a href="#tabAddClient1" id="clientDemo" class="active" onclick="return false">Demographics</a></li>
           <
    li><a href="#tabAddClient2" id="insur" onclick="return false">Insurance1</a></li>        
           <
    li><a href="#tabAddClient3" id="clientFam" onclick="return false">Family Info</a></li>
           <
    li><a href="#tabAddClient4" id="clientMed" onclick="return false">Medications</a></li>
        </
    ul
    How can I rewrite the link and switch statements above so it also specifies which of the tabs is active and which isn't? Or is there a different approach to the active/inactive issue that's better?

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To keep track use a session variable, use an array for the tabs. Use the page name for the key and store either true "1" or false "0" for the value. You can then create a simple function such as isActive() which would check the name and return true or false to determine which tab would be accessable.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That sounds right to me, but it's going to take me awhile to figure out how to implement it. Thanks for pointing me in the right direction.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •