Jump to content

Archived

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

jworisek

dynamic forms

Recommended Posts

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 sizes

Product 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.

Share this post


Link to post
Share on other sites
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

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.