PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamically add multiple rows in a form?

  1. I have a Bill of Lading form created using cforms II in which a user can click a button and add another item row (containing multiple fields such as weight, class, rate, description,etc). The way it is set up right now is that I use JQuery to add another row to the form, and have the user be able to add as many rows as they wish. A customer might ship 2 items, or they might ship 12 pallets of items. There is no upper limit.

    I'd like to convert this form to GForms if possible, but it doesn't seem to save the data I populate it with (using JS). I thought of some hackish ways I can mange this using a single form element, but wanted to check out if there was a much easier way.

    My idea is to create a hidden text field that stores the entire "Shipping item data" in one serialized dump. Assuming I can access injected form elements (say from JavaScript or in HTML blocks) from one of the hooks provided during or before the form is saved. I could also just store all of the data in a separate table(s) for easier access - finer control over the data.

    The client eventually wants to tie this information into users, so clients can log in and view previous entries, and might want to eventually create more complex reports that a stored serialized array would complicate, so maybe storing it separately is best?

    Posted 13 years ago on Monday February 28, 2011 | Permalink