• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

pressing delete button to delete table row

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
look up keycode rather easy to detect with onkeypress

Eric
 
christine clarin
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic