Purusottam Nayak
Query: 22 / Answer: 20

27th Jul 2017 .

Write a JavaScript function to add rows to a table.


Answers

Puspanjali Sahoo
Query: 16 / Answer: 16

27th Jul 2017 .

---------------------html code-------------------------------------

<!DOCTYPE html>
<html><head><meta charset=utf-8 />
<title>Insert row in a table - w3resource</title>
</head><body>
<table id="sampleTable" border="1">
<tr><td>Row1 cell1</td>
<td>Row1 cell2</td></tr>
<tr><td>Row2 cell1</td>
<td>Row2 cell2</td></tr>
</table><br>
<input type="button" onclick="insert_Row()" value="Insert row"> 
</body></html>
 
-----------------end of html code ------------------------------------------
 
-----------------javascript code ------------------------------------------
function insert_Row()
{
var x=document.getElementById('sampleTable').insertRow(0);
var y = x.insertCell(0);
var z = x.insertCell(1);
y.innerHTML="New Cell1";
z.innerHTML="New Cell2";
}
 
-------------------end of javascript code---------------------------------

  •  Information
  • About Forum

    This educational forum is produly developed by betaQsolutions-A leading software company in Odisha. This forum is developed to discuss the educational topics only betweeen the Students, teachers, Parents & Experts. Topic related to Career, Syllabus, Subjects, Questions, Exams etc are allowed to discuss here.

  • Statistics

    Total topics 43 • Total Query 1115 • Total members 247 • Total Answered 1286