473,509 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add new row to a dynamically generated table

7 New Member
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 4615
pbmods
5,821 Recognized Expert Expert
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
thegenius
7 New Member
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 Recognized Expert Expert
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
thegenius
7 New Member
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 Top Contributor
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

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

Similar topics

3
2094
by: Dave Nouwens | last post by:
Hi All, Please accept my appologies in advance for what I expect will be a reasonably simple question. I have an html form (which is generated in php) which contains a number of rows (one row...
3
2309
by: rufus | last post by:
I am created a table dynamically and I have wrapped it in a div tag so that the user can scroll the table horizontally ie I have added an overflow property to the div. I dont want the user to be...
3
10773
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
3
2671
by: Andrew Dodgshun | last post by:
I have 2 grids - one shows a list of table names in a database and when you click on a table name the other grid dynamically populates the grid with the table contents. My problem is that I cannot...
2
2894
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
1
1562
by: Jack Black | last post by:
Not even sure where to start on this one... I need to be able to either: a) set up a SPAN around a dynamically-generated table row (using TableRow object), or b) apply an "onmouseover" property...
2
1122
by: david | last post by:
I have no idea how to get the IDs of dynamically genrated CheckBoxes and the events of CheckedChange. I have dynamically generated array of CheckBoxes, checkboxes,which dynamically display in a...
0
1477
by: KBuser | last post by:
I'm building an internal site which will allow for extremely customizable queries to be run against our SQL Server (2000) DB. The page is done in ASP .net 2.0, with C# code behind. The initial...
7
2534
by: Srikanth Ram | last post by:
Hi, I'm creating a PHP application. In this a dynamic table with the fields in the database is generated in a page. I have placed a checkbox in each row of the table to approve/disapprove...
2
3304
by: mylog | last post by:
Hi I am having a problem of getting the value from the dynamically generated table and dropdownlist. What I am facing is, I have created a table in the aspx page and now I need to add values to...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.