samjsharples Posted August 6, 2014 Share Posted August 6, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/290302-split-items-into-parts-then-create-a-select-list-from-results/ Share on other sites More sharing options...
mac_gyver Posted August 6, 2014 Share Posted August 6, 2014 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. 1 Quote Link to comment https://forums.phpfreaks.com/topic/290302-split-items-into-parts-then-create-a-select-list-from-results/#findComment-1487015 Share on other sites More sharing options...
samjsharples Posted August 6, 2014 Author Share Posted August 6, 2014 Thank you very much. Without knowing the specific term 'chained selects' it is very difficult to find what you're looking for. I will do some research and get cracking. Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/290302-split-items-into-parts-then-create-a-select-list-from-results/#findComment-1487020 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.