jworisek Posted June 23, 2006 Share Posted June 23, 2006 I have a form where the user inputs multiple line items at once and I am currently passing this to the next page using:[code]<select name="blah[]"><option value="">option #1</option>.....</select>[/code]so its it a nice array. I have about 8 inputs per line item so this makes it easy to loop through everything and reconstruct it after submitting since I can use the same index in each option per line item.What I would like to do though is to be able to dynamically update one based on another.for example, lets say we have products and sizesProduct A: Sizes (Small, Medium, Xlarge)Product B: Sizes (Xsmall, Large)Product C: Sizes (Xsmall, Medium, Large, Xlarge)So I want to have the user select the product and then dynamically update the sizes dropdown menu to only the applicable values. I can do this with javascript for one line item, but it fails when I try to use the [] to put the data into arrays. Does anyone have any experience in this sort of thing and have suggestions? I left a message in the javascript forums but no one has posted yet. Quote Link to comment https://forums.phpfreaks.com/topic/12739-dynamic-forms/ Share on other sites More sharing options...
kenrbnsn Posted June 23, 2006 Share Posted June 23, 2006 The only way to do this is with javascript (afaik). Javascript doesn't like arrays in the name attribute, so to get around this, assign a unique id to each <option> and assign the values based on the id.Ken Quote Link to comment https://forums.phpfreaks.com/topic/12739-dynamic-forms/#findComment-48924 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.