SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist -T-'s Avatar
    Join Date
    Jun 2002
    Posts
    444
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Filtering a list With javascript

    I have a list of things, lets say it's movies to make it easy. All of these movies have genres, some have one, some have more then one, What I am trying to do is make a javascript filter that remove the unwanted movies (movies that does not fit the genres selected in the filter form) from the list.

    It can be done by loading the whole list into a two dimensional array, and then regenerate the list every time the filter is changed using javascript. But that sounds very crude and resource demanding, I want it to happen instantly, and with this method it might be very slow on computers with limited resources.

    I thought about giving each item in the list an id and hide them those that does not fit the filter, but I couldn't figure out how to do the actual filtering this way.

    Any other ideas on how to do this more effectively?
    chrome is a wrapper that combines a browser with spyware

  2. #2
    SitePoint Addict CommanderZ's Avatar
    Join Date
    Apr 2006
    Location
    Czech Republic
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd reccomend a server side (possibly ajax) solution.

    Another idea...you can go through the list (or table) and check the genres using DOM functions. And then hide (style.display='none') unwanted items.
    Last edited by CommanderZ; Jun 24, 2007 at 08:59.

  3. #3
    SitePoint Evangelist -T-'s Avatar
    Join Date
    Jun 2002
    Posts
    444
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was thinking about using ajax, but it would make caching some what hard

    Could also filter through it all by using an xml file, but I guess that would give me the same issue as if I loaded it all into a 2 dimensional array

    I think I'll just ignore the resource issue here, looks like the only option, unless someone has a better idea
    chrome is a wrapper that combines a browser with spyware


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
  •