Solved

Form to handle multiple entries

Posted on 2011-09-14
5
251 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
Comment Utility
<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
Comment Utility
How would you deal with multiple form fields with the same name in this circumstance?
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now