Dynamically change element attributes
<p>please help my with this script dynamicField (<a href="http://www.quackfuzed.com/demos/jQuery/dynamicField/index.cfm" rel="nofollow">http://www.quackfuzed.com/demos/jQuery/dynamicField/index.cfm</a>)</p>

<p>Original input element must be:</p>

<pre><code>&lt;input type='text' name='name_1' id='name_1' value='' class='textInput removable' /&gt; 
</code></pre>

<p>But I need this: 
<code>&lt;input type='text' name='name_1[]' id='name_1[]' value='' class='textInput removable' /&gt;</code>  (When I made this, script did not work.)</p>

<p>So I need add <strong>[ ]</strong> behind name_1.
Is necesary edit this code, but I dont know how...</p>

<pre><code>//jQuery dynamicField plugin
//Copyright 2009, Matt Quackenbush (http://www.quackfuzed.com/)

//Find usage demos at http://www.quackfuzed.com/demos/jQuery/dynamicField/index.cfm)
//Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
//and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.

//Version: 1.0
//Date:  8/13/2009

;
(function($) {
    $.fn.dynamicField = function(options) {
        if ( $(this).attr("id") == undefined ) {
            alert("The dynamicField plugin could not be initialized.\n\nPlease check the selector.");
            return $;
    }

    var f = $(this);

    var settings = $.extend({
        maxFields: 5,
        removeImgSrc: "images/icons/cross.png",
        spacerImgSrc: "images/spacer.gif",
        addTriggerClass: "add-field-trigger",
        removeImgClass: "remove-field-trigger",
        hideClass: "hide",
        cloneContainerId: f.attr("id").replace(/^(.+)([_-][0-9]+)$/,"$1"),
        rowContainerClass: f.attr("class"),
        labelText: f.children("label")
                        .html(),
        baseName: f.children("input")
                            .attr("name")
                            .replace(/^(.+[_-])([0-9]+)$/,"$1"),
        addContainerId: "add-" + f.children("input")
                            .attr("name")
                            .replace(/^(.+)([_-][0-9]+)$/,"$1")
                            .replace(/_/g,"-") + "-container"
    },options);

    var getFields = function() {
        return $("div." + settings.rowContainerClass);
    };

    // handle hide/show, etc
    var addRemoveBtnCk = function() {
        var fields = getFields();
        var len = fields.length;

        fields.each(function(i,elem) {
            $(elem)
                .children("img")
                .attr({
                    "src":(len == 1) ? settings.spacerImgSrc : settings.removeImgSrc,
                    "class":(len == 1) ? "" : settings.removeImgClass
                });
        });

        if ( len &gt; (settings.maxFields-1) ) {
            $("div#" + settings.addContainerId).addClass(settings.hideClass);
        } else {
            $("div#" + settings.addContainerId).removeClass(settings.hideClass);
        }
    };

    // handle field removal
    $("img." + settings.removeImgClass).live("click",function() {
        // remove the selected row
        $(this).parent("div." + settings.rowContainerClass).remove();

        // rebrand the remaining fields sequentially
        getFields().each(function(i,elem) {
            var pos = new Number(i+1);
            var d = $(elem)
                        .attr("id",settings.cloneContainerId + "-" + pos);

            d.children("label")
                        .attr("for",settings.baseName + pos)
                        .html((pos &gt; 1) ? "" : settings.labelText);

            d.children("input")
                        .attr({
                            "id":settings.baseName + pos,
                            "name":settings.baseName + pos
                        });
        });

        addRemoveBtnCk();
    });

    // handle field add
    $("div#" + settings.addContainerId + " span." + settings.addTriggerClass).click(function() {
        var len = getFields().length;
        var pos = new Number(len+1);
        var newDiv = f
                        .clone()
                        .attr("id",settings.cloneContainerId + "-" + pos)
                        .addClass(settings.rowContainerClass);

        newDiv.children("label")
                        .attr("for",settings.baseName + pos)
                        .html("");

        newDiv.children("input")
                        .attr({
                            "id":settings.baseName + pos,
                            "name":settings.baseName + pos,
                            "value":""
                        });

        newDiv.children("img")
                        .attr("src",settings.removeImgSrc);

        if ( len &gt; 0 ) {
            $("div#" + settings.cloneContainerId + "-" + len).after(newDiv);
        } else {
            $("div#" + settings.addContainerId).before(newDiv);
        }

        addRemoveBtnCk();
    });
};
})(jQuery);
</code></pre>

<p>Thank you all.</p>
