Add/remove row to table with unique Id
<p>This is my javascript to copy row and remove row</p>

<pre><code>function cloneRow()
 {
         var row = document.getElementById("r1"); 
         var table = document.getElementById("t1"); 
         var clone = row.cloneNode(true); 
         clone.id = "newID";
         table.appendChild(clone); 
 }
 function removeRowFromTable()
 {
 var tbl = document.getElementById('div1');
 var lastRow = tbl.rows.length;
 if (lastRow &gt; 1) tbl.deleteRow(lastRow - 1);
 }
</code></pre>

<p>and this is my table:</p>

<pre><code> &lt;table id="div1" style="display:none"&gt;
    &lt;tbody id="t1"&gt;
    &lt;tr id="r1"&gt;&lt;td&gt;
&lt;form:input path="hostname" value="hostname" onfocus="if(this.value == 'hostname'){this.value =''}" onblur="if(this.value == ''){this.value ='hostname'}" size="30" maxlength="30"/&gt;
&lt;form:input path="directory" value="directory" onfocus="if(this.value == 'directory'){this.value =''}" onblur="if(this.value == ''){this.value ='directory'}" size="15" maxlength="15"/&gt;
&lt;form:input path="username" value="username" onfocus="if(this.value == 'username'){this.value =''}" onblur="if(this.value == ''){this.value ='username'}" size="15" maxlength="15"/&gt;
&lt;form:input path="password" value="password" onfocus="if(this.value == 'password'){this.value =''}" onblur="if(this.value == ''){this.value ='password'}" size="15" maxlength="15"/&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;/tbody&gt;
&lt;input type="button" onclick="cloneRow()" value="+" /&gt;
&lt;input type="button" onclick="removeRowFromTable();" value="-" /&gt;
    &lt;/table&gt;
</code></pre>

<p>code is working to add or remove the rows dynamically..but, how can I know they are creating with unique ids..i need to save the values to database later on</p>
