Help with JavaScript and MySQL

Discussion in 'JavaScript' started by rfeio, May 5, 2010.

  1. #1
    Hi,

    I have these two MySQL tables (location, properties). Each location can have one or more properties so both tables are related using Keys.

    What I'm trying to implement is an HTML form where when a user selects a location then the system automatically filters the properties results accordingly.

    The "location" list is loaded from MySQL using PHP, but obviously PHP doesn't allow me to filter the "properties" list while the selection is at the user side.

    I thought that this may be done using JavaScript? I don't know JavaScript so any help would be greatly appreciated.

    Cheers!
     
    rfeio, May 5, 2010 IP
  2. Bagi Zoltán

    Bagi Zoltán Well-Known Member

    Messages:
    364
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Hi,

    You will have to implement an ajax get request to achieve the desired behaviour. When the select is changed the you will have to execute get request using value of the selected option as query string. The target URL will process the query string and give back the html code of the second dropdown accordingly executing the sql query. When the result is ready the js will adopt the response to a target DOM element.

    Good luck
    Zoli
     
    Bagi Zoltán, May 5, 2010 IP