» » Use Jquery to copy form element

 

Use Jquery to copy form element

Author: bamboo06 on 2-04-2016, 16:19, views: 3258

50
When we submit the form, sometimes you encounter the need to repeat the same form to add multiple elements, such as order information you need to add a number of different types of products, form data in the new field information. This time we can put a "new one" or "Copy" button directly on the form, you can achieve copy form elements by clicking on the button.


HTML
In this article we copy a simple plug-in jQuery based elements introduced by way of example, by calling the plug-in element easily copy function.
First, load the jQuery library file and copy the plug element duplicateElement.min.js.
<script src="jquery.js"></script> 
<script src="duplicateElement.min.js"></script> 

We assume that you want to copy user information element, forms html structure is as follows:
<form id="myform" name="myform" action="post.php" method="post">
	<fieldset id="additional">
		<label for="name">Name: </label><input id="name" name="name[]" type="text" class="input" >
		<label for="flag">Level: </label>
		<select id="flag" name="flag[]">
			<option disabled="" selected="">Select</option>
			<option value="1">VIP</option>
			<option value="2">VIP2</option>
		</select>
		&nbsp;
		<a href="javascript:void(0);"  class="btn remove">Remove</a>
		<a href="javascript:void(0);"  class="btn create">Copy</a>
	</fieldset>
	
	<br/>
	<div class="sub_btn">
		<input type="submit" class="button" value="Submit">
	</div>
</form>


jQuery
We click on the "Copy" button, the contents of the #additional copy, the equivalent of a new row, the initial display when only the "copy" button to copy after the original piece will show "Remove" button, click "remove" to remove the corresponding row can be.
    $(function () { 
        $('#additional').duplicateElement({ 
            "class_remove": ".remove", 
            "class_create": ".create", 
            onCreate: function (el) { 
                el.find("select").prop('defaultSelected'); 
                el.find(".input").val(''); 
            } 
        }); 
    }); 

We can also add callback() function to define attributes new form elements after succeeded copying, such as form elements value or style and so on through onCreate.

Category: Javascript

Dear visitor, you are browsing our website as Guest.
We strongly recommend you to register and login to view hidden contents.
<
  • 0 Comments
  • 0 Articles
31 July 2017 01:39

Natalia Gardner

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
I think that from now, I will have to use Jquery to copy form element. If the best custom paper writer agreed, there's not much else to say now is there? It's been proving just oh so good an experience using the application. Java's not too difficult to handle I suppose.

<
  • 0 Comments
  • 0 Articles
14 August 2017 21:38

Izabella Spears

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
This is really great, glad that now we can use Jquery to copy form element especially for the granite kitchen counters site. Well the process seems easy to copy and proceed with after all, thanks for the good post.

<
  • 0 Comments
  • 0 Articles
26 September 2017 23:39

Lauren sinclair

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Parece tener sentido comun, porque la pornografia, y el sexo en general, se sienten tan bien, que podrian convertirse en adictivos. Tambien tiene sentido intuitivo que, porque el sexo libera neuroquimicos en el cerebro, que esos neuroquimicos podrian actuar como drogas en el cerebro. chicas tetonas

<
  • 0 Comments
  • 0 Articles
2 October 2017 20:13

BlackMen

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
This was a truly incredible challenge and ideally I can go to the following one. It was alot of fun and I truly lived it up.. https://www.youtube.com/watch?v=CT5LGjw1KCc

<
  • 0 Comments
  • 0 Articles
4 October 2017 17:08

Claudia Zayne

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
javascript can scare too. Someone that is unfamiliar to it, yet in the event that you comprehend the fundamentals (loops, restrictive articulations, capacities, and so on) you can learn it rapidly. javascript is a question situated programming dialect. website explainer video to explain. On the off chance that you don't comprehend the ideas of question situated programming, you will be constrained in working with javascript.

<
  • 0 Comments
  • 0 Articles
16 October 2017 22:41

BlackMen

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
I am upbeat to discover this post exceptionally helpful for me, as it contains part of data.foodie blogs

<
  • 0 Comments
  • 0 Articles
26 October 2017 10:49

jacob william

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Quote

Sin embargo, el estudio encontró que los hombres que miran imágenes sensuales de mujeres realizaron un 50 por ciento mejor en una area de matemáticas de una prueba de estrés en comparación con los chicos que miraban fotos no sexuales.Los investigadores concluyeron por lo tanto, que mirando las imágenes redujo la respuesta al estrés en el cerebro.
voyance amour

<
  • 0 Comments
  • 0 Articles
6 November 2017 04:26

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
i adore perusing this article so beautiful!!great work! Love commands

<
  • 0 Comments
  • 0 Articles
17 November 2017 21:59

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Awesome web journal you have here. You"ll find me taking a gander at your stuff regularly. Spared! betboo

<
  • 0 Comments
  • 0 Articles
18 November 2017 04:06

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Incredible data! I as of late went over your web journal and have been perusing along. I thought I would leave my first remark. I don't recognize what to say with the exception of that I have. Parali rulet

<
  • 0 Comments
  • 0 Articles
18 November 2017 23:19

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
I went over this site and I trust you have a ton of brilliant data, spared to my bookmarks online bahis

<
  • 0 Comments
  • 0 Articles
19 November 2017 16:59

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
A debt of gratitude is in order for sharing this data. I truly like your blog entry all that much. You have truly shared an instructive and fascinating blog entry with individuals.. Jobs & career

<
  • 0 Comments
  • 0 Articles
24 November 2017 22:29

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
nice post, keep up with this interesting work. It really is good to know that this topic is being covered also on this web site so cheers for taking time to discuss this! Travel guide

Good focuses you composed here..Great stuff...I think you've made some really fascinating points.Keep up the great work. casino filmleri

<
  • 0 Comments
  • 0 Articles
25 November 2017 21:20

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
this is truly pleasant to read..informative post is great to read..thanks a considerable measure! blackjack siteleri

<
  • 0 Comments
  • 0 Articles
27 November 2017 17:11

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Hey, I discover perusing this article a delight. It is amazingly useful and intriguing and all that much anticipating perusing a greater amount of your work.. Doctors Tips Online

<
  • 0 Comments
  • 0 Articles
27 November 2017 20:28

peter

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
American Sentinel’s doctorate in nursing education is intentionally designed to develop the six key competencies most needed by today’s nursing education leaders: Business law

I needed to thank you for this extraordinary read!! I unquestionably appreciating each and every piece of it I have you bookmarked to look at new stuff you post. Jobs & career

<
  • 0 Comments
  • 0 Articles
27 November 2017 21:14

peter

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
I as of late ran over your website and have been perusing along. I thought I would leave my first remark. I don't realize what to say with the exception of that I have delighted in perusing. Decent blog. I will continue going to this web journal regularly. Home improvement

<
  • 0 Comments
  • 0 Articles
28 November 2017 22:23

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
There are many people who have to face many different problems to find all things at one place. People who are facing this type of problem not have to worry now. We are providing all things at one place at Global store. You can get all Global store

I read that Post and got it fine and educational. It would be ideal if you share more like that... Kids health

<
  • 0 Comments
  • 0 Articles
29 November 2017 17:17

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
A debt of gratitude is in order for posting this information. I simply need to tell you that I simply look at your site and I discover it exceptionally fascinating and useful. I can hardly wait to peruse loads of your posts. marketing

<
  • 0 Comments
  • 0 Articles
29 November 2017 17:52

peter

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
I needed to thank you for this extraordinary read!! I unquestionably appreciating each and every piece of it I have you bookmarked to look at new stuff you post. Jobs & career

<
  • 0 Comments
  • 0 Articles
2 December 2017 22:12

BachJohann

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Nice Informative Blog having nice sharing.. VIP Romanian Escorts

<
  • 0 Comments
  • 0 Articles
4 December 2017 04:22

BachJohann

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Unlike other blogs I have read which are really not that good. visit this site hurry up waiting your order Thanks alot! yachtowners.org.uk

<
  • 0 Comments
  • 0 Articles
5 December 2017 21:55

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
This is a genuinely decent site post. Not very numerous individuals would really, the way you simply did. I am truly inspired that there is such a great amount of data about this subject have been revealed and you've given a valiant effort, with so much class. On the off chance that needed to know more about green smoke surveys, than by all methods come in and check our stuff. Business courses

<
  • 0 Comments
  • 0 Articles
11 December 2017 09:15

BachJohann

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. http://www.rideandsail.com/

<
  • 0 Comments
  • 0 Articles
12 December 2017 02:32

BachJohann

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
It's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards, brian holm lawyer san diego

<
  • 0 Comments
  • 0 Articles
12 December 2017 23:21

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
A debt of gratitude is in order For sharing this Superb article.I utilize this Article to demonstrate my task in college.it is helpful For me Great Work. Transportation

<
  • 0 Comments
  • 0 Articles
17 December 2017 17:34

Robinjack

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
This one is great. keep doing awesome!.. Green tech

<
  • 0 Comments
  • 0 Articles
17 December 2017 21:59

BachJohann

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
This is a savvy blog. I would not joke about this. unifycosmos.com

<
  • 0 Comments
  • 0 Articles
18 December 2017 00:28

AvaAddams

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
excellent expertise gaining article. This submit is actually the quality on this precious topic.Wedding Dress makers

<
  • 0 Comments
  • 0 Articles
18 December 2017 22:01

phd thesis writing services

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Thanks for sharing amazing information !!!!!!
Please keep up sharing.

phd thesis writing services

Previous Next
Information
Comment on the news site is possible only within (days) days from the date of publication.