Revision: 6487
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 23, 2008 12:51 by dmosher
Initial Code
<script type="text/javascript" charset="utf-8"> $(function() { var fieldCount = 1; $("#addFieldButton").click(function() { fieldCount++; 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 />" ); } else { alert("Maximum email fields reached."); } }); }); </script>
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
JavaScript