Return to Snippet

Revision: 6487
at May 23, 2008 12:51 by dmosher

Initial Code
<script type="text/javascript" charset="utf-8">
	$(function() {
		var fieldCount = 1;
		$("#addFieldButton").click(function() {
			if(fieldCount <= 5)
				var fieldID = "recipient_email_" + fieldCount;
				$("#additionalEmails").append("<label for='"+fieldID+"'>Recipient Email "+fieldCount+": </label>"+ 
											  "<input type='text' name='"+fieldID+"' " +
											  "id='"+fieldID+"' size='30'><br />" );
				alert("Maximum email fields reached.");

Initial URL

Initial Description
I wrote this very quickly for a form I parse that allows a user to send a page to up to 5 friends. The script adds a click event to an image of a + sign beside an input box. When clicked if the user hasn't already added 5 friends to email, additional email boxes will be added.

Initial Title
jQuery Dynamic Form Field Addition

Initial Tags
javascript, forms, jquery

Initial Language