Jump to content

auto-create cell in html using javascript


Thoaren

Recommended Posts

Hi,

 

I'm pretty new in Javascript. I searched alot but didn't find any answer to my problem I have.

 

What I want to do:

- I have a cell A1

- I want the script to make a new cell B1

- After that I want the script to make a new cell C1

- After that I want the script to make a new cell D1

- After that I wa .... etc .... till I got 20 cells in total.

 

This has to go automatic so not by use of a client sided button.

 

I also need every cell to get his own IDnumber like A1 ID=1, B1 ID=2, C1 ID=3, etc to communicate with database and mysql. But maybe I have to use php for that.

 

Thanx for any help!  ;D

 

Best regards,

 

Thoaren

If you want this to happen automatically and not by some user action, then why don't you just build the table with 20 cells to begin with? JavaScript has it's uses, but if you want 20 cells by default, JavaScript is not the way to go.

On top of what mjdamato said, this sounds like you'll be using an HTML table-tag.  My experience with dynamically creating tables and elements with DOM is that it works like crap in some browsers.  You're much better off creating a DIV and doing something like:

mydiv.innerHTML = '<table><tbody><tr><td>A</td><td>B</td></tr></tbody></table>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.