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

this is table..

Recommended Answers

All 4 Replies

you can do this by javascript..
try this link.

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..

change this line to:

<a href="javascript:addRow('dataTable');" > add</a>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.