SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Additional filtering after drop down box displays data on change?

    Hi All.

    Basically, I have a drop down box that is dynamically generated. When a user picks an item, a table is displayed containing data fetched from MySQL. This is done with the help of AJAX. I am using this example here: http://www.w3schools.com/PHP/php_ajax_database.asp

    This all works fine, my data is displayed fine. Now, I have the requirement of after displaying this data, again be able to filter it by date.

    I suppose what I need to do is display the data as seen above and also display another drop down after something is selected, and then allow the users to further filter based on this newly displayed dropdown. I am not really sure how to accomplish this, the AJAX example I posted above only seems to let you pass one variable, if I could pass 2 variables I could probably manage this.

    Has anyone had to do anything similar, I cant seem to find much on the internet, other than dependent dynamic dropdowns.

    Thanks for any and all help!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,001
    Mentioned
    186 Post(s)
    Tagged
    2 Thread(s)
    If passing more than one variable wil do the trick, you can do it like the example does (sid is the second variable).
    HTML Code:
    var url="getuser.php";
    url=url+"?q="+str;
    url=url+"&sid="+Math.random();
    url=url+"&another="+whatever;
    url=url+"&again="+something;
    The only thing I wonder about is if the & should be & instead.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    If passing more than one variable wil do the trick, you can do it like the example does (sid is the second variable).
    HTML Code:
    var url="getuser.php";
    url=url+"?q="+str;
    url=url+"&sid="+Math.random();
    url=url+"&another="+whatever;
    url=url+"&again="+something;
    The only thing I wonder about is if the & should be & instead.
    Thanks for the reply. I suppose my problem is, how do I pass this new value from my select box to the above AJAX code?

    For instance, the html code for the select is as simple as this:
    <select onchange="showUser(this.value)" name="wc">

    This passes the value of the select to the ajax. If I want to have another variable available to AJAX, how do I actually pass it from my select drop down above? As you outlined, once I have the variable I can do as you mentioned, just not sure how to get it?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,001
    Mentioned
    186 Post(s)
    Tagged
    2 Thread(s)
    Yes, I guess you can't have more than one onchange event at a time. But you could do a document.getElementById('second_var').value


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
  •