call javascript function for dynamically populated textbox
<p>Hi i have generated textboxes dynamically using javascript. and i wrote a function to find time difference. 
if i populate 4 rows of textboxes(more than one row), then the function will work for first row only. 
i couldnt access that function for remaining rows.</p>

<p>canu give me any suggestion for this?</p>

<p>Thanks in advance.</p>

<p>Code for dynamically populate textboxes</p>

<pre><code>function addChl_Element()
{
    var num_box = document.getElementById("num_2g_halt_text").value;    
    if(!isNaN(num_box))
    { 

        for(var i=0; i&lt;num_box; i++)    
        {      
            var oldTable=document.getElementById('halttable');
            var bBox = oldTable.getElementsByTagName('tbody')[0];
            var newRow=document.createElement('tr');
            var newTimeDown = document.createElement('td');
            var newDateDown = document.createElement('td');
            var newTimeBack = document.createElement('td');
            var newDateback = document.createElement('td');
            var newDurationOutage = document.createElement('td');
            newSiteName.innerHTML = "&lt;input type='text' name='site_name3[]'      id='site_name3'&gt;";
            newTimeDown.innerHTML = "&lt;input type='text' name='time_down3[]' id='time_down3'&gt;";
            newDateDown.innerHTML = "&lt;input type='text' name='date_down3[]' id='date_down3'&gt;";
            newTimeBack.innerHTML = "&lt;input type='text' name='time_back3[]' id='time_back3'&gt;"; 
            newDateback.innerHTML = "&lt;input type='text' name='date_back3[]' id='date_back3'&gt;"; 
            newDurationOutage.innerHTML = "&lt;input type='text' name='duration_of_outage3[]' id='duration_of_outage3' onfocus = 'dura2(this.value);'&gt;"; 


            newRow.appendChild(newTimeDown);
            newRow.appendChild(newDateDown);
            newRow.appendChild(newTimeBack);
            newRow.appendChild(newDateback);
            newRow.appendChild(newDurationOutage);
            bBox.appendChild(newRow);
        }
    }
}
</code></pre>

<p>Code for Function to find time difference:</p>

<pre><code>function dura2()
{
    var date_bk = document.getElementById("date_back3").value;
    var time_back = document.getElementById("time_back3").value;
    var date_down = document.getElementById("date_down3").value;
    var time_down = document.getElementById("time_down3").value;
    var testArr = new Array();
    testArr[0] = date_bk;
    testArr[1] = time_back;
    var down=new Array();
    down[0] = date_down;
    down[1] = time_down;
    var back_dur = new Date(testArr.join(" "));
    var down_dur = new Date(down.join(" "));
    var duration = Math.abs((back_dur) - (down_dur));
    var cr_dr = Math.round(duration/60/1000);
    document.getElementById("duration_of_outage3").value = cr_dr;
}
</code></pre>
