Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Two Combo box in a form control each other (http://www.go4expert.com/forums/combo-box-form-control-t24350/)

azadms 3Jan2011 14:48

Two Combo box in a form control each other
 
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.

pein87 4Jan2011 06:21

Re: Two Combo box in a form control each other
 
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.

azadms 4Jan2011 08:07

Re: Two Combo box in a form control each other
 
Quote:

Originally Posted by pein87 (Post 76845)
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.

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.

pein87 4Jan2011 11:24

Re: Two Combo box in a form control each other
 
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.


All times are GMT +5.5. The time now is 09:19.