Archive for the ‘JavaScript’ Category
delete HTML table row dynamicaly using javascript
Tuesday, September 30th, 2008Following code is used to delete the html table row(<tr>) dynamically using javascript. Just press the delete button and deletes the <tr> as well as <td>'s from the table. <html> <head> <script type="text/javascript"> function delete_row(r) { var i=r.parentNode.parentNode.rowIndex; //calculates the index of the row to delete document.getElementById('tasksTable').deleteRow(i); //deletes the row } </script> </head> <body> <table id="tasksTable" border="1" width="400"> <tr> <td>Row 1</td> <td><input type="button" value="Delete" onclick="delete_row(this)"></td> </tr> <tr> <td>Row ...
Add new row dynamically to existing table
Sunday, September 28th, 2008Often we want to add the rows dynamically in our applications. This can be done using passing some parameter to add one more row (<TR>). But this method reloads the page again. Using JavaScript we can add the new row(<tr>) very easily. Following example shows how to add new row ...
Disable browser back button using javascript
Sunday, June 8th, 2008Some times after filling the form, user oftenly clicks on back button to go back. We can disable this back button using javascript in the following way <script language="JavaScript"> <!-- history.go(+1); // --> </script> <script> javascript:window.history.forward(1); </script> This script sends the user to the same page where he/she is clicking the back button. In another way its just disables ...