Multiple Select in Forms and Logging to DB
Posted 28 August 2005 - 08:39 PM
A Member could be a distributor for N number of Parent Companies .
He Could represent All or N Divisions of a Parent Company.
The Parent Companies could be anything from 400 - 600 and will be updated as and when New Companies are found.
Each Parent Company could have N number of Divisions within itself.
I have created these Tables
1.Table Parent_Companies (data entered by Admin)
Columns - Company_ID (Autoincremented), CompanyName
Columns - Company_ID, Division_ID(Autoincremented), DivisionName
The DivisionName are entered thru a form by Admin. This Form has CompanyName values as dropdown, but returns the respective Company_ID to the Table2
Columns - Distributor_ID, CompanyDivision
Now this where I'm stuck
I would like to have the Member Select the Company Divisons he represents from a Form. Since the Companies data would be in 1000s, I dont want to use a Drop-Down.
I presume that a 25 Line List-Box would be a better option from which Companies can be added to another multi-line Text-box. The Options in the ListBox should be concatenated as "Parent Company - Division".
How do I do this? I've found a java script that does the Adding/ Removing between the ListBox and TextBox. But I've not been able to figure out how I could store each "Parent Company - Division" as a record in Table3. (I dont want to store as an array)
I understand that I need to use a Loop here, just cant figure out how to do it.
Also, how would I able to genrate a mail to the Admin with details of all the Parent Company - Divisions when the Member submits the Form?
On the other hand, would it be easier to key in the Divisions as "Parent Company - Division" itself in the 1st place in Table1 and avoid Table2?
Is there a simple solution or am I complicating things?
Thanx for the support
Posted 27 October 2005 - 06:39 PM
a list box with 1000's of records? then what :S
Let me know what you're trying to do and i'll see if i can come up with some code for you
Posted 28 October 2005 - 11:20 AM
Lemme make it simpler :-)
Each Member is a distributor of pharmaceutical products. Naturally, each one is a distributor for several manufacturing companies.
There are 1300+ companies.
The member has to Login and is taken to a page where these Companies are Listed. I thought a ListBox would be the best option to present this. The Companies are populated from another table and are referred by their equivalent ID.
Now the Member can select multiple companies he represents and the information needs to be stored as Member_Id / Company_Id in another table. But I dont want to store the information as an array, rather as separate records.
My queries now :
Would it be possible to display the 1300+ Companies in any other manner ? Multi-page options are out as it would be cumbersome for the Registrant.
I tried some java so that the Member can select a company and "ADD: it to another empty Box alongside. But I'm getting some errors.
Thanks for the support
Posted 28 October 2005 - 11:51 AM
But have a few of them in a row (let me explain).
The first one, you could have listing the starting letter of the company.
then have an onChange function on the select box to submit that form which would reload the page and display another select box with the categories etc....
The each time the page is loaded just filter the database results using WHERE=$someVar.
I am sure there is another way using AJAX to get it to work without having to reload the page, but i havent started to look at that...
If you do do this, dont forget to $_POST all the variables in the form otherwise they will be lost on the reload.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users