Thoaren Posted March 4, 2010 Share Posted March 4, 2010 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! Best regards, Thoaren Quote Link to comment https://forums.phpfreaks.com/topic/194130-auto-create-cell-in-html-using-javascript/ Share on other sites More sharing options...
Psycho Posted March 4, 2010 Share Posted March 4, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/194130-auto-create-cell-in-html-using-javascript/#findComment-1021589 Share on other sites More sharing options...
roopurt18 Posted March 4, 2010 Share Posted March 4, 2010 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>'; Quote Link to comment https://forums.phpfreaks.com/topic/194130-auto-create-cell-in-html-using-javascript/#findComment-1021617 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.