How To Delete the textbox using the Javascript



This topic is to delete the textbox/textarea/selectbox which will be created dynamically in the application using javascript

if you need to delete the rows just u need to select that check box and go for the delete button .

You can have this code for using in your application this must be related to the button which you will use in your application

the Code is


function deleteRow() {
try {
var table = document.getElementById(‘myTable’);
//alert(‘table’+table);
var rowCount = table.rows.length;

for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && false == chkbox.checked) {
table.deleteRow(i);
rowCount–;
i–;
}

}
}catch(e) {
alert(e);
}
}

<INPUT type=”button” value=”Delete Row” onclick=”deleteRow()” />

Random Posts

  • Define Stateless Session
  • Main Exceptions in Thread
  • Define Session Migration
  • Springs Interview Questions
  • EJB Interview questions
  1. 1 Comment(s)

  2. By Venkat on Feb 9, 2010 | Reply

    Hi,

    Your site is very nice and informative, having lots of java stuff. I have a blog on Java, Please let me know if you are interested for link exchange

    http://java-j2ee-technologies.blogspot.com

    Cheers
    Venkat

Post a Comment