SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2002
    Location
    Washington D.C
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamic lists using dropdowns

    I'm in the process of trying to find a way to generating an unordered list from selections made from a form dropdown menu. I would like to us php since I am most familiar with it. Also I not able to use javascript for accesibility reasons. So I'm guessing either a session must be created or parameters must be passed in order for this to work.

    Here is an example:

    A user is given a drop down with four options

    -Menu1
    -Menu2
    -Menu3 (User Selects this option)
    -Menu4

    Users clicks on the next page then is given another dropdown

    -Submenu1
    -Submenu2 (User selects this option)
    -Submenu3

    Once the form is submitted the html output would look something like this


    <h1>Menu3</h1>
    <ul>
    <li>Submenu1</li>
    <li class="highlight">Submenu2</li>
    <li>Submenu3</li>
    </ul>

    The menu selected determines which ul is displayed.

    Does anybody have any ideas on what a good approach would be to accomplish this task?

  2. #2
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are a few ways of accomplishing what you want, but as you've mentioned, Sessions are the best choice.

    First place you should look is the Session Handling section on PHP.net.

    From the first page, before you do anything else, you need to start the session:
    PHP Code:
    <?php

        
    // begin site session
        
    session_name('session_name');

        
    session_start();

    ?><?php
    This needs to be repeated on all pages where you intend to make use of the Session.

    If you name one of your drop-down / pop-up menus pmenu1, then once this page has been submitted, you can access this variable via $_POST['pmenu1'] or $_GET['pmenu1'], depending on what method you use.

    Then, you would add that variable to you session by:
    PHP Code:
    $_SESSION["pmenu1"] = $_POST['pmenu1']; 
    From thereon in, to access any Session variable, simply call:
    PHP Code:
    $_SESSION["sessionVarName"
    Hope that helps?

  3. #3
    SitePoint Addict kirikintha's Avatar
    Join Date
    Nov 2004
    Location
    Boulder, CO
    Posts
    290
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have to use this fix for IE as well for your session
    PHP Code:
    @header("Cache-control: private"); //IE 6 Fix 
    myspace.com/tarsus
    Technical Coordinator
    BCMT
    "Not impossible, just hard to do!"

  4. #4
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kirikintha
    I have to use this fix for IE as well for your session
    PHP Code:
    @header("Cache-control: private"); //IE 6 Fix 
    What exactly does that fix?

    I'm not familiar with that...

  5. #5
    SitePoint Addict kirikintha's Avatar
    Join Date
    Nov 2004
    Location
    Boulder, CO
    Posts
    290
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    with IE 6 my session vars just seemed to disappear when going between pages or executing code so, I was reading about this

    Microsoft Internet Explorer Sessions Fix

    There is one other little tricky issue I must tell you about. Since we all know even though Microsoft makes every attempt to dominate the world, their software still has issues. Let's take IE 6 for example. There's a problem with IE6 that when you are using sessions and you post to a form, when you click your back button to make changes in the form, you have to click the REFRESH button on that page to get the information that you posted back into the form. This only works about 50% of the time, the other 50% the users information is lost and they have to type it over again. Not a good thing if you are trying to get the person to enter their billing information to process an order. They might just get irritated and leave. So, here's a solution for that. Enter this right below the session_start() of each script (yes it still must be before anything is output to the browser).
    header("Cache-control: private");

    Now your users can hit the back button and change information all they want! Whew... no need to sweat any more.
    myspace.com/tarsus
    Technical Coordinator
    BCMT
    "Not impossible, just hard to do!"

  6. #6
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And people wonder why I use a Mac and nothing but a Mac!

    I'll add this issue to the very, very, very long list of reasons I don't use a Microsoft operating system...

  7. #7
    SitePoint Addict kirikintha's Avatar
    Join Date
    Nov 2004
    Location
    Boulder, CO
    Posts
    290
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my favorite thing I saw here was

    function deathray($Microsoft)

    IMHO Microsoft is allowed to put out a product that doens't work and can even harm people. They put a recall out on vehicles that hurt people, they put warnings out for tobacco, alcohol, but MS is allowed to put out a product that is faulty and they don't care - it's just riduculous - I must admit to not being a fan of any OS (I have tons of linux, unix and MAC issues as well) - but considering that MS is the widest used and these people are making trillions off of us, we're all getting scammed becaue the have pretty GUI
    myspace.com/tarsus
    Technical Coordinator
    BCMT
    "Not impossible, just hard to do!"

  8. #8
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, with all of that said (and I do whole-heartedly agree with you!) we're firmly off-topic, here...


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
  •