Jump to content


dynamic forms

  • Please log in to reply
1 reply to this topic

#1 jworisek

  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 23 June 2006 - 04:04 PM

I have a form where the user inputs multiple line items at once and I am currently passing this to the next page using:

<select name="blah[]"><option value="">option #1</option>.....</select>

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.

#2 kenrbnsn

  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 June 2006 - 09:50 PM

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.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users