Web Development Question (filtering)

Discussion in 'Technology' started by trance_fan, Feb 21, 2007.

Users Viewing Thread (Users: 0, Guests: 0)

  1. trance_fan

    trance_fan Registered User

    Joined:
    Nov 7, 2002
    Messages:
    9,022
    Likes Received:
    0
    Web Development Question (filtering)

    As part of the site im building a user has the option to filter to only show a certain catagory eg. "Oustanding Issues" or "Resolved Isses" etc.

    Now, I've coded this in PHP, whereby it takes the value currently set in a list/menu and selects the certain records based on the if statements.

    Now....in dreamweaver I have the default set to "Outstanding Calls" - at the minute when i alter the menu option, nothing happens...which is expected since i have not coded this yet.

    My question is...firstly...how do i force a page refresh when you choose a new optiona and secondly...and indeed more importantly...how do i get the page to remember that the option has been changed and only display the corresponding records?

    Could I perhaps have a "Go" link or whatever, which will then refresh the page...passing a value into the URL which is then taken up in the code?

    At the minute, it works if i manually alter the default value for the list/menu.

    Slightly stumped!!

    Input appreciated :)
  2. 1615634792921.png
  3. Yosef Ha'Kohain

    Yosef Ha'Kohain Registered User

    Joined:
    Nov 11, 2001
    Messages:
    20,386
    Likes Received:
    5
    Location:
    Zion
    Re: Web Development Question (filtering)

    javascript will do it automatically, submitting the form to itself will do it at the click of a button :)
  4. Jason Bourne

    Jason Bourne Registered User

    Joined:
    Oct 14, 2002
    Messages:
    5,258
    Likes Received:
    0
    Could you not post the page to itself?
    You can do that in ASP.. probably can do it in PHP too..
  5. Yosef Ha'Kohain

    Yosef Ha'Kohain Registered User

    Joined:
    Nov 11, 2001
    Messages:
    20,386
    Likes Received:
    5
    Location:
    Zion
    as i said you can submit the form to itself... but you need to trigger it by javascript or a button.

    you dont have all the asp short cuts, which remove the fun and the understanding from coding ;)
  6. ManofScience

    ManofScience Guest

    ....
  7. trance_fan

    trance_fan Registered User

    Joined:
    Nov 7, 2002
    Messages:
    9,022
    Likes Received:
    0
    ok so i have made the page refresh, but the menu option isn't being remembered.....

    Ideas?
  8. Yosef Ha'Kohain

    Yosef Ha'Kohain Registered User

    Joined:
    Nov 11, 2001
    Messages:
    20,386
    Likes Received:
    5
    Location:
    Zion
    pass it in the query string or as a hidden variable in the form.

    <input type="hidden" name="var1" value="$choice">
    or
    page.php?var1=$choice

    depending how you refresh the page.
  9. trance_fan

    trance_fan Registered User

    Joined:
    Nov 7, 2002
    Messages:
    9,022
    Likes Received:
    0
  10. trance_fan

    trance_fan Registered User

    Joined:
    Nov 7, 2002
    Messages:
    9,022
    Likes Received:
    0
    well i've only gone and cracked it at last!

    <select name="filter" id="filter" onchange="location.href=filter.options[selectedIndex].value">
    <option selected="selected">Issue Filter...</option>
    <option value="userhome.php?filter_id=1" >All Issues</option>
    <option value="userhome.php?filter_id=2" >Outstanding Issues</option>
    <option value="userhome.php?filter_id=3" >Resolved Issues</option>

    </select>

    Glorious.

Share This Page