| | |
Add / remove table row. javascript
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Please feel free to modify this code to match your needs. If you have any question regarding this code you can document.write('Me on my inbox'). lol! Have a good day...
html Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Some Title</titles>
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- BEGIN HIDING function addRow() { /* A quick example on how to add and delete table rows. Enjoy coding! */ var _table = document.getElementById('table1').insertRow(0); var cell0 = _table.insertCell(0); var cell1 = _table.insertCell(1); cell0.innerHTML = 'New Cell1'; cell1.innerHTML = 'New Cell2'; } function removeRow(rows) { var _row = rows.parentElement.parentElement; document.getElementById('table1').deleteRow(_row.rowIndex); } // DONE HIDING --> </script>
html Syntax (Toggle Plain Text)
</head> <body> <table id="table1" border="1"> <tr> <td>Row1 cell1</td> <td>Row1 cell2</td> </tr> <tr> <td>Row2 cell1</td> <td>Row2 cell2</td> </tr> <tr> <td>Row3 cell1</td> <td>Row3 cell2</td> </tr> </table> <br /> <input type="button" onclick="addRow()" value="Add Row" /> <input type="button" onclick="removeRow(this)" value="Del Row" /> </body> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
![]() |
Similar Threads
- Dynamically add rows to a form (JavaScript / DHTML / AJAX)
- Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource (PHP)
- Add remove rows javascript problem.... (JavaScript / DHTML / AJAX)
- Hi guys please clear my doubt. (ASP.NET)
- AJAX generated <select> and FIREFOX (JavaScript / DHTML / AJAX)
- dynamic combo load problems (PHP)
- javascript to add select button (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: AJAX read specific id tag & count tag in external html
- Next Thread: Tech help pls
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxjspservlets array browser bug calendar captchaformproblem cart checkbox child class close codes createrange() cursor date debugger decimal dependent disablefirebug dom dropdown editor element embed engine enter events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post programming progressbar prototype redirect regex runtime safari scale scriptlets scroll search security shopping size software sql text textarea toggle unicode web windowsxp wysiwyg \n





