Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Form to handle multiple entries

Posted on 2011-09-14
5
Medium Priority
?
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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)

715 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