Jump to content

Archived

This topic is now archived and is closed to further replies.

DontheCat

Multiple Select in Forms and Logging to DB

Recommended Posts

am creating a website for a Pharma Distributors Association. The Members could be representing various Pharmaceutical Companies. This is the Scenario.

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

 

2.Table Divisions

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

 

3.Table Distributor_Companies

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

Share this post


Link to post
Share on other sites

hi, not quite sure i understand what you're trying to do?

 

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 :)

 

Chris

Share this post


Link to post
Share on other sites

Thanks Chris,

 

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

Share this post


Link to post
Share on other sites

You could still use a <select> box...

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.