Two Combo box in a form control each other

Discussion in 'PHP' started by azadms, Jan 3, 2011.

  1. azadms

    azadms New Member

    Joined:
    Jan 3, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    On php page in a form, One combo box has list of my Customer from mysql table customer. Another combo box has invoiceno stored in invoice table which has respective customer records. I want to select customer from first combo box and filter invoiceno from the second one according to the first one for the respective customer. Any one help me for php or java or both codings? Means if I select customer1 then in the second combo box should show all invoiceno respective to the custermer1.
     
  2. pein87

    pein87 Active Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    28
    Occupation:
    Web Dev
    Location:
    Limbo
    Do you want page refresh or no page refresh? You can use a url variable to this. Then use that as the where condition in your SQL statement that returns that persons invoices.
     
  3. azadms

    azadms New Member

    Joined:
    Jan 3, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I do not want page refresh or Reload or POST the form. Even if I get the first combobox selection as a variable in php mens $abc then I can use it in the where condition in the SQL. But how to get the variable from first selection box. Normal $_GET not working until POST the form.
    Any help pl.
    On php page in a form, One combo box has list of my Customer from mysql table customer. Another combo box has invoiceno stored in invoice table which has respective customer records. I want to select customer from first combo box and filter invoiceno from the second one according to the first one for the respective customer. Any one help me for php or java or both codings? Means if I select customer1 then in the second combo box should show all invoiceno respective to the custermer1. No Refresh or Re Load or Post the form.
     
  4. pein87

    pein87 Active Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    28
    Occupation:
    Web Dev
    Location:
    Limbo
    You need to use Ajax to do this. Forgive me but my javascript is terrible since I haven't coded in it in a while but you need to set up an ajax request to that when the value of the select box is change it will send a request to the server to display that persons invoices. You can use

    selectedIndex and onchange to get the trigger to work.

    selectedIndex gets the current value that is selected and onchange is an event when the value is changed. Of course you will need to either addEventListener() or attachEvent() depending on the browser and use a ajax function to be the trigger that is called when the selectedIndex value changes. Since my JS is bad I really cant go any further than this hope this helps you some what.

    If ajax is out of the question have a standard form that uses the value of the select box as the value being used in the query.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice