Adding text values to dynamically create text inputs
<p>I am trying to build a dynamic form. I have the clone and masking down along with it submits and post to my database but now I am trying to take the value from the previous id #endtime_* and make it the value of the new dynamically created input field of #starttime_*. The ids start with 1. For Example: the first row is:  then next is 2 and so on.</p>

<p>As a bonus maybe someone could also tell me how to make each created row alternate in color. odd rows blue and even rows white say.</p>

<p>Thanks so much in advance!</p>

<p>Here is the code thus far.</p>

<pre><code>    &lt;script type="text/javascript"&gt;
        function maskInput(){
            $.mask.definitions['~'] = "[+-]";
            $(".time").mask("99:99 aa");

            $("input").blur(function() {
            $("#info").html("Unmasked value: " + $(this).mask());
        }).dblclick(function() {
            $(this).unmask();
        });
        }
        var clone;
        function cloneRow(){
            var rows=document.getElementById('TimeCard').getElementsByTagName('tr');
            var index=rows.length-1;
            clone=rows[index-0].cloneNode(true);
            var inputs=clone.getElementsByTagName('input'), inp, i=0,n ;
            while(inp=inputs[i++]){
                inp.name=inp.name.replace(/\d/g,'')+(index+1);
            }
            var select=clone.getElementsByTagName('select'), sel, i=0,n ;
            while(sel=select[i++]){
                sel.name=sel.name.replace(/\d/g,'')+(index+1);
            }
        maskInput();
        }
        function addRow(){
            var tbo=document.getElementById('TimeCard').getElementsByTagName('tbody')[0];
            tbo.appendChild(clone);
            cloneRow();
        }
        function checkDOM(){
            var rows=document.getElementById('TimeCard').getElementsByTagName('tr');
            for(var i=0;i&lt;rows.length;i++){
                alert(rows[i].getElementsByTagName('input')[0].name);
            }
        }
        onload=cloneRow;
        &lt;/script&gt;
</code></pre>
