Duplicating a text field in the form

duplicate
This guide will show you how to add a link that the click to add another text field below an existing one, useful if you need them to enter variable pieces of data. Add an HTML element (from the “More” tab) to the form, right below the text field, and enter the content below then customise it to suit.

1
2
3
45
6
7
8
9
10
11
12
13
<a id="add-another" href="#">Add another</a>
<script>
    jQuery(document).ready(function ($) {
        var $field = $('.iphorm_1_1');        $field.attr('name', $field.attr('name') + '[]');
 
        $('#add-another').click(function () {
            var $clone = $field.clone();
            $clone.val('').css({ display: 'block' }).appendTo($field.parent());
            return false;
        });
    });
</script>
<a id="add-another" href="#">Add another</a>
<script>
    jQuery(document).ready(function ($) {
        var $field = $('.iphorm_1_1');
        $field.attr('name', $field.attr('name') + '[]');

        $('#add-another').click(function () {
            var $clone = $field.clone();
            $clone.val('').css({ display: 'block' }).appendTo($field.parent());
            return false;
        });
    });
</script>
  • On line 4 replace .iphorm_1_1 with the unique ID of the text field

Still having trouble? Head over to the forums.

Forums