Jump to content

split items into parts, then create a select list from results


samjsharples

Recommended Posts

Hi. I will try and explain simply.

 

I have a list of item codes eg. 

size1 Acolor1

size1 Bcolor3

size1 Bcolor1

size1 Acolor3

size1 Acolor4

size2 Acolor1

size3 Bcolor1

size3 Bcolor2

size3 Bcolor2

size3 Acolor1

 

I want to take these and split them into parts:

 

size1 Acolor2

size1 Bcolor3

etc.

 

Then I want to create a form with 2 dropdowns. The first option would just have all unique sizes so:

size1

size2

size3

 

Then when one is selected, option 2 would show the colours available in that size.

 

Is there a standard way of doing this? Can I use PHP to create the array and then jquery to display and hide the options?

 

I'm totally stuck and i'm not just looking for somebody to code it all for me. any help would be greatly appreciated

 

thanks

Sam

Link to comment
Share on other sites

Then when one is selected, option 2 would show the colours available in that size.

 

 

this is called a 'chained select'.

 

you can do it using mostly php (the first select menu choice is submitted to the server and php retrieves the relevant data and builds the second select menu) or any combination of php/javascript.

 

for the solutions using javascript, for a relatively small amount of total data, you can output all the data on the page (as a javascript array or object) when the page is requested and use javascrpt to populate of the second select menu as needed or you can use ajax to retrieve the relevant data from the server on demand to populate the second select menu.

  • Like 1
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.