Dynamically creating and appending many divs and form elements to a form

Hello, all.

I know the basics of appending a form element to a form using jQuery; but if I have MANY form elements that I want to incrementally create based upon the value of a select, is it possible to create one object that contains all the divs and form elements, and just use that as part of a loop to create multiple sets of form elements?

For example, say I have a form that is to be used for getting a quote on shipping. It has one static section for sender information (name, address, city, state, zip), one static section for destination (same fields), but will allow the sender to ship anywhere from one to 30 packages, dynamically set by user choice of a select, and that each package requires information (description, type, dimensions, weight, hazardous Y/N, stock number, comments), can I create one object that has all these fields and their containing divs and iterate that to create a set of fields for each package?

V/r,

:slight_smile:

Hi Wolfshade;

Just want to share my idea on the approach that I have in mind to do it is like;

  1. Store the information using JSON.
  2. Stored information has their own ids, product and source.
  3. Access and get each information using URI and getJson function.
  4. The getJson will be inside your JS that will also contain the loops.
  5. The JS has the append function and you could ue switch case or if else to filter the app logic.
  6. Make sure that you will handle properly the bubble stuff of JQ.

Hope this could help.

Good luck!

Best regards,
Warly

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.