0

is it possible, that when a user clicks an image,
it will automatically add a row to the table?

this is table..

Attachments Image5.png 2.33 KB
2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by xuexue
0

yes sir, i already got in here..but i wanted to change it using a link..could you check it?

<HTML>
<HEAD>
    <TITLE> Add/Remove dynamic rows in HTML table </TITLE>
    <SCRIPT language="javascript">
        function addRow(tableID) {
 
            var table = document.getElementById(tableID);
 
            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);
            cell2.innerHTML = rowCount + 1;
 
            var cell3 = row.insertCell(2);
            var element2 = document.createElement("input");
            element2.type = "text";
            cell3.appendChild(element2);
 
        }
    </SCRIPT>
</HEAD>
<BODY>
 
    <p>&nbsp;</p>
    <TABLE id="dataTable" width="350px" border="1">
<TR>
            <TD><INPUT type="checkbox" name="chk"/></TD>
            <TD> 1 </TD>
            <TD> <INPUT type="text" /> </TD>
        </TR>
    </TABLE>
    <p>
      <INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />
    </p>
    <p><a href="add_row.php" onClick="addRow('dataTable')"> add</a></p>
</BODY>
</HTML>

i put the code instead of the button is the link but what happens is that
after it adds, it automatically deletes the added row..

Edited by xuexue: n/a

0

that was really great sir,
i got it already!
thanks for the help!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.