Jump to content

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

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.