Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add rows + columns on table dynamically. How?

Status
Not open for further replies.

josel

Programmer
Oct 16, 2001
716
US
I am about to start working on a data entry grid. I would like to write it so that the user starts off with two rows ...

As the user presses TAB on bottom right cell, I want to add another row - This is the same as those visual HTML editors or MS Word, etc.

Your assistance will be much appreciated!

Regards,


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
You can attach an onkeypress or onkeydown event handler to each cell in the last column, something like:

Code:
cellRef.onkeypress = checkForTab;

then write a function to detect the tab key, something like:

Code:
function checkForTab(evt) {
   var keyCode = (evt) ? evt.keyCode : event.keyCode;
   if (keyCode == 9) {
      // tab key was pressed
   }
}

Then you can do your extra logic, adding rows and / or columns however you'd like. I'd investigate methods such as "insertRow", and "insertCell". See here for more information on building tables dynamically:


Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
BillyRay,

I will give it a try right this moment ... I will report back shortly.

Sorry but I've been hit in all directions and had to put this program on hold.

Regards,


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
I gave it a try but cannot get the effect I am looking for. I am sure that I am not doing it correctly ... I will stay on it until I get it ...

This is something I think will be nice to have on a up-and-coming project.

Regards,


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top