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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.