Error when remove row using javascript?
<p>I have a sample code:</p>

<pre><code>&lt;input type="checkbox" id="input_modem_1" onclick="add_delete_row(this, 1,'test1' )" name="modem_id[]" value="1" /&gt; test 1
&lt;input type="checkbox" id="input_modem_2" onclick="add_delete_row(this, 2,'test2' )" name="modem_id[]" value="2" /&gt; test 2
&lt;table id="modem_list"&gt;&lt;/table&gt;
</code></pre>

<p>And code javascript:</p>

<pre><code>&lt;script&gt;
function add_delete_row(element, id, modem_name) {
    if(element.checked) {
        if(id) {
            deleteRow(id);
        }
        addRow(id, modem_name);
    } else {
        deleteRow(id);
    }
}
function addRow(id, modem_name) {
    var table = document.getElementById("modem_list");

    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);

    var cell1 = row.insertCell(0);
    var element1 = document.createElement("input");
    element1.type = "checkbox";
    cell1.appendChild(element1);

    var cell2 = row.insertCell(1);
    var element2 = document.createElement("input");
    element2.type = "hidden";
    element2.value = id;
    cell2.innerHTML = modem_name;
    cell2.appendChild(element2);
}
function deleteRow(id) {
    try {
        $('modem_list').removeChild($('modem_'+id));
        $('modem_list').removeChild($('input_modem_'+id));
    } catch(err){}
}
&lt;/script&gt;  
</code></pre>

<p>When I check on a value is result add a row, and when i uncheck this row, is result not run and it add more this, how to fix it           </p>
