aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes pressing delete button to delete table row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "pressing delete button to delete table row" Watch "pressing delete button to delete table row" New topic
Author

pressing delete button to delete table row

christine clarin
Ranch Hand

Joined: Feb 05, 2005
Posts: 106
hi, please help me with my problem... i need to delete a row after (left) clicking on it and then pressing the delete button on the keyboard. I can already do the part where the row catches my (left) click but after that, i don't know how to use the delete button.. how do i do it? i also already have the code for deleting the row but I can't call it unless I know how to call on delete. thanks! hoping for your help...thank you!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
look up keycode rather easy to detect with onkeypress

Eric
christine clarin
Ranch Hand

Joined: Feb 05, 2005
Posts: 106
Thanks! I used onkeyup event, however, i can't seem to pass a variable or an argument to my function. this is what i have:

//where row is the row I want to delete
function checkRow (row, event)
{
if (window.event.button == 2)
{*rightclick code*}
//left click code
else if (window.event.button == 1) {
if( document.captureEvents && event.KEYUP ) {
document.captureEvents( event.KEYUP );
}
document.onkeyuf = doSomething;
}
}

function doSomething (e){
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
alert('Character was ' + character);
}

this works, that is, i'm getting the keycode that i want to, but i want to also pass the row variable that i have from check row so i could do deleteRow (row.rowIndex) in doSomething but when i do this:

document.onkeyuf = doSomething (row);
...
function doSomething (row, e) {
...
alert('Character was ' + character);
}

the keycode i always get is the one for left click and i don't get to press delete anymore after my alert. why is that? how do i solve this? thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pressing delete button to delete table row