Results 1 to 4 of 4

Thread: Ajax (?) dropdown menu to pull info from MYSQL database

  1. #1
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax (?) dropdown menu to pull info from MYSQL database

    Hi there

    I'm not sure if I'm posting this in the correct section...

    I need to create three dropdown boxes (box 1:colour, box 2: price, box 3:brand) and when the user presses "GO" they are returned with the correct information, pulled from corresponding fields in my MYSQL database.

    For example, colour: silver, price 100-200, brand:samsung...should return 5 items on the page.

    I do not need the dropdown boxes to populate depending on the previous selection - they are static, so to speak. If possible, I would also like the information to be returned on the page without the URL changing, which I think will involve ajax...?

    I am not sure how to do this and appreciate any help at all, even if it is sending me to a tutorial on how to do this.

    Many thanks in advance

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Yes, this is AJAX... However, you'll also need a server-side (e.g., PHP) script to do the actual database lookup. For example, you might use database.php?colour=silver&price=100-200&brand=samsung in the AJAX request, and database.php would be responsible for getting the information and printing it in a way that your JavaScript could understand.

    As for a tutorial, there are loads, and your use case isn't all that special from a code perspective. http://www.google.com/search?hl=en&q=ajax+tutorial
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. #3
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi

    Thanks for your reply. I use php to pull info from my database onto my page already. My stumbling block is putting it all together for these new purposes, I can't seem to get my head around it exactly!

    Does anyone have anything a bit more specific to get me started?

    Many thanks

  4. #4
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Do you know how to get the values of the select elements? In case not, here are some resources:
    http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-94282980
    http://www.w3schools.com/htmldom/dom_obj_select.asp
    (I would give the Mozilla Developer Center link for this, but it strangely doesn't exist.)
    http://msdn.microsoft.com/en-us/libr...93(VS.85).aspx
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

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
  •