home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
showing results for how to add rowin html tabel by js
1<HTML>
2<HEAD>
3	<TITLE> Add/Remove dynamic rows in HTML table </TITLE>
4	<SCRIPT language="javascript">
5		function addRow(tableID) {
6
7			var table = document.getElementById(tableID);
8
9			var rowCount = table.rows.length;
10			var row = table.insertRow(rowCount);
11
12			var colCount = table.rows[0].cells.length;
13
14			for(var i=0; i<colCount; i++) {
15
16				var newcell	= row.insertCell(i);
17
18				newcell.innerHTML = table.rows[0].cells[i].innerHTML;
19				//alert(newcell.childNodes);
20				switch(newcell.childNodes[0].type) {
21					case "text":
22							newcell.childNodes[0].value = "";
23							break;
24					case "checkbox":
25							newcell.childNodes[0].checked = false;
26							break;
27					case "select-one":
28							newcell.childNodes[0].selectedIndex = 0;
29							break;
30				}
31			}
32		}
33
34		function deleteRow(tableID) {
35			try {
36			var table = document.getElementById(tableID);
37			var rowCount = table.rows.length;
38
39			for(var i=0; i<rowCount; i++) {
40				var row = table.rows[i];
41				var chkbox = row.cells[0].childNodes[0];
42				if(null != chkbox && true == chkbox.checked) {
43					if(rowCount <= 1) {
44						alert("Cannot delete all the rows.");
45						break;
46					}
47					table.deleteRow(i);
48					rowCount--;
49					i--;
50				}
51
52
53			}
54			}catch(e) {
55				alert(e);
56			}
57		}
58
59	</SCRIPT>
60</HEAD>
61<BODY>
62
63	<INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />
64
65	<INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
66
67	<TABLE id="dataTable" width="350px" border="1">
68		<TR>
69			<TD><INPUT type="checkbox" name="chk"/></TD>
70			<TD><INPUT type="text" name="txt"/></TD>
71			<TD>
72				<SELECT name="country">
73					<OPTION value="in">India</OPTION>
74					<OPTION value="de">Germany</OPTION>
75					<OPTION value="fr">France</OPTION>
76					<OPTION value="us">United States</OPTION>
77					<OPTION value="ch">Switzerland</OPTION>
78				</SELECT>
79			</TD>
80		</TR>
81	</TABLE>
82
83</BODY>
84</HTML>
85
upvote
downvote
source
1<table id="tbl">
2    <tr>
3        <td><input type="text" name="links" /></td>
4        <td><input type="text" name="keywords" /></td> 
5        <td><input type="text" name="violationtype" /></td>   
6        <td><input type="submit" class="button" value="Add another line" onclick="addField(this);" /></td>          
7    </tr>
8</table>
upvote
downvote
source
queries leading to this page
js table addcreate table row in javascript dynamicallyjavascript dynamic tablehow to insert a table row for every employee dynamically using javascriptjavascript add tr td to tablehow to dynamically add row to a table javascriptjavascript table dynamic rowonlcick insert row in table in jshow to add row in html tabel by jsadd table dynamically in javascriptadd row dynamically javascriptjavascript table add rowjavascript table that adds row dynamichow to add new row in table on button click in javascript with next numbertable dynamic row number in jsinsert data into specific column cell using javascripthow to add a row to a table jsjavascript how to add rows to table dynamicallyjavascript table add row depending on datatabel tr td dynamicallyjavascript function to add a row to a table dynamicallyjavascript table add row dynamically in different rowbutton to add a tr from table javascriptcreate table dynamically using javascript jquery sqlhow to create new rows with js using buttonsdynamically add or remove table rows in javascript and save data to a databasehow to put thing in a row jsonclick add row table javascriptadd row to bottom of table in jshtml dynamic rowsadd dynamic row to table using javascriptadd dynamically row in table javascriptadd many row using button onclick javascripthow to add row in html table dynamically using javascripthow to add dynamic row in javascripton click addrow jshow to add table rows dynamically in javascriptjavascript add new row on button clickjs dynamically add new row for tabledynamic adding of data for table using jsinsert a row through jsjavscript add row with javascriptjavascript add row to table endcreating a new row for data with create element in javascripthtml add rows to table automaticallygenerate table rows dynamically javascriptdynamically add row in html table using javascriptadd row onclick javascriptadd table row dynamically using javascriptonclick function to add rowadd row with text to table javascriptwith list name how to add row and remove row in javascriptadd table row dynamically javascriptadd td to tr javascriptjs dynamically add rows to tabledynamically add table rows jsadd new row in table on button click using javascriptinsert row to table jsdynamic tables javascriptinsert rows dynamically javascript tablehtml create a table with add row buttonusing javascript to insert row in tablejs table insert trdynamically add rows in a table in javascriptjavascript add data to table dynamicallyvanilla js add rows to tableadding row based on the value in htmladd a row in html on button clickcreate dynamic row table using javascriptjavascript add rows to table dynamicallyadding a row to a table in html dynamicallyjs to add another row to formincrease table row dynamically javascript htmljavascript button to add row to tablenew row in javascriptadd row html javascript designjavascript add new row onclickjs dynamic tablehow to add row dynamically in table using javascriptjavascript append table rowjavascript dynamically add row to tabledynamic data into rows html tableadd table row javascriptadd or remove table rows dynamically using javascriptdynamic data into rows htmlhow to add rows to a table dynamically in javascripthow do you add and remove rows dynamically in a table 3fjs add new table row on clickhow to add row in table with js dynamicallyjs onclick add new row for tableadd new row on button click using javascripthow to add row and column in html table dynamically using javascript and save themdynamically add table rows javascriptjs dynamically add rows table write a javascript function to add rows to a tablejs button add new row for tablejavascript add row to tablejavascript onclick add row to tablehow to add dynamic rows in a table with javascriptcreated row jswrite a javascript function to add rows to a table html code to create a table rows dynamicallyjs add row on button clickadd line table javascriptjavascript add row botton clickjavascript onclick append a new row to tabledynamic row adding in javascripthow to append table row in javascriptinner html adding extra tr tags tablehow to add new row in table on button click in javascriptadd row to table on button click in javascriptjavascript add new table row each clickhow to add a row dynamically in table in javascriptecreate a new row in a table each time function in javascriptwhen i dynamically add table rows javascriptjavascript add another rowcreate row in table javascripthow to add row onclick in javascripthow to add row in existing table in jsadd row with fields dynamically javascript add element to table on clickadd rows on click with a plus button javascriptjavascript create table row dynamicallyappend a tablerow javascriptadd table row dynamicallyjs add row to tableadd dynamic data to table row and insert it to domadding dynamic table rows javascriptadd row using javascriptjs table for add row dynamiccreate dynamic table with rowspan javascript add rows th to html table javascripthow to append tr in table using javascriptcreate a new row in jsdynamically add value to table data javascriptjavascript data insert in table dynamicwrite a javascript function to add rows to a tablejavascript add rows to table depend dynamically add table dynamic jsjavascript add row to table dynamically exampleadd table values automatically in a dynamic table javascripthow to create table rows dynamically in javascriptadd row on click of buttonhow to make row 28 29 dynamicdynamic table row creation in javascriptcreate dynamic table rows in javascripthow to add row and column in html table dynamically using javascriptdynamically add data to table using javascripthow to add dynamic table row from javascriptonclick intsert new row in table jshow to add row to table in js dynamicallyadd table and row dynamic jshow to insert a new row into the table dynamicallyappend row to table javascriptadd a row in table javascript on click of buttonappend row to table jswrite the javascript function to add a row on the table every time the insert row button is clicked dom add row to table dynamically jstable tr add td dynamically javascriptadd row to table dynamically javascriptadd new row to table with button javascriptadding rows of a table together javascripthow to add row in existing html table dynamically using javascriptadd table rows dynamically using javascriptjavascript onclicka dd item to tableadd dynamic tr in htmljavascript with table add rowhow to insert dynamic values in html tablehow to append a button in every row in a table using javascriptjavascript dynamic table row adddynamic add table row in javascriptadd row to table javascript dynamiccreate table rows dynamically in javascript