469,632 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

Add new row to a dynamically generated table

Hi everyone,

I have a database that stores some info,
In a php page, the dataare retrieved to generate a table.

the question is,
how can I add or delete a row from this table ?

to specify more, the same as the phpMyAdmin procedure but on the page

sure i have to add some buttons and drop down menu

but i need your help to create the code :)

thanks in advance
Sep 29 '07 #1
5 4446
pbmods
5,821 Expert 4TB
Heya, TheGenius.

Create a 'Dolly' node:
Expand|Select|Wrap|Line Numbers
  1. <table style="display: none;">
  2.     <tr id="dolly">
  3.         .
  4.         .
  5.         .
  6.     </tr>
  7. </div>
  8.  
Then to add a row:
Expand|Select|Wrap|Line Numbers
  1. var newRow = document.getElementById('dolly').cloneNode(true);
  2. newRow.id = '';
  3.  
  4. document.getElementById('idOfTable').appendChild(newRow);
  5.  
Sep 29 '07 #2
Heya, TheGenius.

Create a 'Dolly' node:
Expand|Select|Wrap|Line Numbers
  1. <table style="display: none;">
  2.     <tr id="dolly">
  3.         .
  4.         .
  5.         .
  6.     </tr>
  7. </div>
  8.  
Then to add a row:
Expand|Select|Wrap|Line Numbers
  1. var newRow = document.getElementById('dolly').cloneNode(true);
  2. newRow.id = '';
  3.  
  4. document.getElementById('idOfTable').appendChild(newRow);
  5.  

can you plz explain a bit more?
I created the Js file, addrow.js
I created the table
now is there will be a button to call the function from the js file right ?
can you tell me how to call it

thanks in advance
Sep 30 '07 #3
pbmods
5,821 Expert 4TB
Heya, TheGenius.

Simply create a function that clones the Dolly node, removes its ID and attaches it to the table similarly to what I posted above.
Sep 30 '07 #4
Hey,

well i'm not too many into javascript and functions :D
so an example with details would be very appreciated
Oct 2 '07 #5
dmjpro
2,476 2GB
Heya, TheGenius.

Create a 'Dolly' node:
Expand|Select|Wrap|Line Numbers
  1. <table style="display: none;">
  2.     <tr id="dolly">
  3.         .
  4.         .
  5.         .
  6.     </tr>
  7. </div>
  8.  
Then to add a row:
Expand|Select|Wrap|Line Numbers
  1. var newRow = document.getElementById('dolly').cloneNode(true);
  2. newRow.id = '';
  3.  
  4. document.getElementById('idOfTable').appendChild(newRow);
  5.  

Expand|Select|Wrap|Line Numbers
  1. var newRow = document.getElementById('dolly').cloneNode(true);
  2.  
Really this is very appreciating :-)
I don't have to write a lot of codes, just copy the row and get the results :-)
I am really enjoying this.

Kind regards,
Dmjpro.
Oct 2 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Dave Nouwens | last post: by
1 post views Thread by Jack Black | last post: by
2 posts views Thread by david | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.