Solved

Form to handle multiple entries

Posted on 2011-09-14
5
256 Views
Last Modified: 2012-05-12
I have a form with 12 fields. This form submits the information for registering a student for courses that we offer. Currently, it only handles one registration at a time and is kind of clunky.

I want to present the user the capability to register more than one person at a time. Essentially adding multiple users' info at once before submitting the form.

I also want to have an area above the form that shows a list of people that they enter in a select, which will later be modified to have checkboxes so they may remove them, if needed.

Anyone know of any tutorials or sample showing how to do something like this using jQuery?
0
Comment
Question by:EddieShipman
  • 3
  • 2
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36540262
<div id="I_WANT_TO_BE_CLONED" style="display:none">
here all the fields for a registration. It should be the content of your current form
</div>

you add a button to add a new user registration somwhere in your page:

<input type="button" id="ADD_NEW_USER_REGISTRATION" value="ADD USER REG" />

your form is by default empty (or with one user reg. if you want)

now we need to clone thediv and put it (add it) add the end of your form
additionaly, we need to unhide (show()) the cloned version :

$("#ADD_NEW_USER_REGISTRATION").click(function(e) {
    $("#I_WANT_TO_BE_CLONED").clone().show().appendTo("form");
})

Open in new window


BASIC TEST PAGE : http://jsfiddle.net/Qewnb/



0
 
LVL 26

Author Comment

by:EddieShipman
ID: 36540581
How would you deal with multiple form fields with the same name in this circumstance?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36540589
each set of fields (a user reg.) is inside a div
on the server side, you get an array of fields for a given name
you just need to loop over it for each one

you don't have multiple forms, just one
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36540600
we've an empty form
a set of fields outside this form
each time we click on the button, we clone the set of fields to add to the form
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 36542829
I an not sure that you would get an array of fields if they had the same name unless they were named name="field_xxx[]"
I understand that there is only one form. Look at how these do it:

http://www.jdmweb.com/resources/formclone
http://code.google.com/p/sheepit/

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
parse url to form? 7 37
ASP.NET MVC 5- How can I post textarea value using @Html.ActionLink? 8 53
How Close unsubmited attempts 10 42
Jquery 7 28
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question