Welcome Guest, Not a member yet? Register   Sign In
Dynamically add rows in a table in php mvc


I want to know that how can dynamically add rows working in php mvc.
i found a code i.e.:

    <TITLE> Add/Remove dynamic rows in HTML table </TITLE>
        function addRow(tableID) {

            var table = document.getElementById(tableID);

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

            var colCount = table.rows[0].cells.length;

            for(var i=0; i<colCount; i++) {

                var newcell = row.insertCell(i);

                newcell[removed] = table.rows[0].cells[i][removed];
                switch(newcell.childNodes[0].type) {
                    case "text":
                            newcell.childNodes[0].value = "";
                    case "checkbox":
                            newcell.childNodes[0].checked = false;
                    case "select-one":
                            newcell.childNodes[0].selectedIndex = 0;

        function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length;

            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    if(rowCount <= 1) {
                        alert("Cannot delete all the rows.");

            }catch(e) {


    &lt;INPUT type="button" value="Add Row"  /&gt;

    &lt;INPUT type="button" value="Delete Row"  /&gt;

    <TABLE id="dataTable" width="350px" border="1">
            <TD>&lt;INPUT type="checkbox" name="chk"/&gt;&lt;/TD>
            <TD>&lt;INPUT type="text" name="txt"/&gt;&lt;/TD>
                <SELECT name="country">
                    <OPTION value="in">India</OPTION>
                    <OPTION value="de">Germany</OPTION>
                    <OPTION value="fr">France</OPTION>
                    <OPTION value="us">United States</OPTION>
                    <OPTION value="ch">Switzerland</OPTION>


pls can anyone suggest me that how can i implement in php mvc.
thanks in advance for any help.

add those functions to a controller then call them via form's action attribute.

Theme © iAndrew 2016 - Forum software by © MyBB