Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd and Delete Rows from a html table by user input from text box using only javascript
    primarykey
    data
    text
    <p>I am trying to make a program using HTML and java-script a program in which user can add content and delete from HTML table what ever row he wants to delete I made it but only one cell is edited by text box and other are not getting the values of there text box please do some help to complete my task as it'll be very appreciated. </p> <p>My code is: </p> <pre><code>&lt;!Doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Transitiona//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html&gt; &lt;head&gt; </code></pre> <p>Javascript maybe this my javascript code is not correct written please get any solution for my task</p> <pre><code> &lt;script type="text/javascript"&gt; function delrow0() { document.getElementById("myTable").deleteRow(0); } function displayResult() { var table=document.getElementById("myTable"); var row=table.insertRow(0); var cell1=row.insertCell(0); var cell2=row.insertCell(1); var cell3=row.insertCell(2); cell1.innerHTML=document.getElementById('txtname').value; cell2.innerHTML=document.getElementById('txtauthor').value; cell3.innerHTML=document.getElementById('txtcontent').value; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; </code></pre> <p>HTML </p> <pre><code>&lt;table id="myTable" border="1"&gt; &lt;tr&gt; &lt;td&gt;cell 1&lt;/td&gt; &lt;td&gt;cell 2&lt;/td&gt; &lt;td&gt;cell 3&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;cell 4&lt;/td&gt; &lt;td&gt;cell 5&lt;/td&gt; &lt;td&gt;cell 6&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br&gt; &lt;button type="button" onClick="displayResult()"&gt;Insert new row&lt;/button&gt; &lt;button type="button" onClick="delrow0s()"&gt;delete&lt;/button&gt; &lt;form name="create"&gt; Name:&lt;input type="text" id="txtname" /&gt;&lt;br/&gt; Author&lt;input type="text" name="txtauthor" /&gt;&lt;br/&gt; CDate:&lt;input type="text" name="txtcdate" /&gt;&lt;br/&gt; CDate:&lt;input type="text" name="txtcontent" style="height:80px; " /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Fiddle <a href="http://jsfiddle.net/FVA9L/" rel="nofollow"><code>here</code></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload