How to create a counter in jquery
<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;

&lt;script src="../plugin/jquery-1.6.1.min.js"&gt;&lt;/script&gt;
&lt;script src="../plugin/jquery.validate.min.js"&gt;&lt;/script&gt;
&lt;script src="../plugin/jquery.form.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" type="text/css" href="../style/form.css" /&gt;
&lt;script&gt;
$(document).ready(function() {
    $("#add").click(function() {
        var id = "input" + $(this).attr("id").replace("field","");
        var intId = $("#buildyourform div").length + 1;
        var fieldWrapper = $("&lt;div class=\"fieldwrapper\" id=\"field" + intId + "\"/&gt;");
        var fName = $("&lt;input type=\"text\" id=\"" + id + "\" name=\"" + id + "\" class=\"fieldname\" /&gt;");
        var fType = $("&lt;select class=\"fieldtype\"&gt;&lt;option value=\"checkbox\"&gt;Checked&lt;/option&gt;&lt;option value=\"textbox\"&gt;Text&lt;/option&gt;&lt;option value=\"textarea\"&gt;Paragraph&lt;/option&gt;&lt;/select&gt;");
        var removeButton = $("&lt;input type=\"button\" class=\"remove\" value=\"-\" /&gt;");
        removeButton.click(function() {
            $(this).parent().remove();
        });
        fieldWrapper.append(fName);
        fieldWrapper.append(fType);
        fieldWrapper.append(removeButton);
        $("#buildyourform").append(fieldWrapper);
    });
});

&lt;/script&gt;


&lt;/head&gt;
&lt;body&gt;
&lt;div id="stylized" class="myform"&gt;
&lt;form id="edit" method="post" action="config.php" &gt;
&lt;fieldset id="buildyourform"&gt;
    &lt;legend&gt;Build your own form!&lt;/legend&gt;
&lt;/fieldset&gt;
&lt;input type="button" value="Add a field" class="add" id="add" /&gt;
&lt;input type="submit"&gt;
&lt;div class="spacer"&gt;&lt;/div&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>This is the code of a  dynamic form , however, currently the text box name and select box name is 'inputadd', i would like to change it to input1, input2, input3, that means when user add a field , it will be counter+1 and the name of text field , select field will be that string, and the same if remove counter -1 , How can i modify the code to achieve this?Thank you</p>
