SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2010
    Posts
    503
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best Way to Filter?

    Hi all, it's something I've been needing to do for a while, and that is to filter results on the page such as my example below (although they use ASP.NET but you can get a feel of what I'm wanting to achieve). Quite like their way with check-boxes to filter.

    Click here to view example.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    They're using javascript there, but you don't want to entirely rely on that.

    First, get it working without javascript, where the checkboxes have an [Update] submit button, and the page includes a separate PHP script to process the form fields and provide the appropriate content.

    Once that fundamental base layer is working, you can use scripting to remove the [Update] submit button, and on a change of the checkbox you can request the content via AJAX instead.

    Get the fundamentals working first though, otherwise you'll be screwed when client-side scripting is not available.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2010
    Posts
    503
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there, thanks for your message. Ok I see, so it's probably best to head away from the Javascript approach? It's a useful thing to be able to do, just not 100% sure on how to achieve this. Gerrr!

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by coxdabd View Post
    Hi there, thanks for your message. Ok I see, so it's probably best to head away from the Javascript approach?
    Yes, only because you can always guarantee your PHP server being there, but you cannot guarantee that the client runs the JavaScript code.

    Quote Originally Posted by coxdabd View Post
    It's a useful thing to be able to do, just not 100% sure on how to achieve this. Gerrr!
    There's a good book called Bulletproof AJAX, which also provides the code and demo pages online, which takes you through these issues and how to successfully handle them.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •