473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Cloning / creating new row to my 3 column table(noob btw!)

Hi guys this is my first post an ive only started to use HTML, PHP and mySQL so here goes.

The problem I am having is that i want a single line table to duplicate more lines of code when an onClick button is pressed. it basically goes

Staff name Wage hours worked
I:::::::I I:::::::::::::I I:::::::::::::::::I IButtonI

When the button is pressed i want the form table to change to
Staff name Wage hours worked
I:::::::I I:::::::::::::I I:::::::::::::::::I
I:::::::I I:::::::::::::I I:::::::::::::::::I IButtonI

and so on. I am storing staff name etc as an array so i can easily calculate totals. Is there a way to do this dynamically without having to show / hide or else using DOM?

Any help appreciated!
Sep 5 '08 #1
5 1143
eWish
971 Expert 512MB
This will require the use of JavaScript or DHTML. Moving to JavaScript/DHTML/Ajax Forum.

--Kevin
Sep 5 '08 #2
RamananKalirajan
608 512MB
Hi hope this code will hep u out

[HTML]<html>
<head>
<script type="text/javascript">
function doThis()
{
var myTab = document.getElementById('myTable');
var row=myTab.rows.length;
var y=myTab.insertRow(row);

var a=y.insertCell(0);
var xx= document.createElement('input');
xx.type="text";
a.appendChild(xx);

var b=y.insertCell(1);
var xx= document.createElement('input');
xx.type="text";
b.appendChild(xx);

var c=y.insertCell(2);
var xx= document.createElement('input');
xx.type="text";
c.appendChild(xx);

}
</script>

</head>
<body>
<br/>
<input type="button" value="Add" onclick="doThis()">
<br/>
<table id="myTable" border="1" cellspacing="5" cellpadding="5">
<tr>
<th>Name</th>
<th>Wage</th>
<th>Hours Worked</th>
</tr>
</table>
</body>
</html>[/HTML]

Regards
Ramanan Kalirajan
Sep 5 '08 #3
Ferris
101 100+
there's an example in W3 schools.
http://www.w3schools.com/js/tryit.as...able_insertrow

Regards.
Sep 5 '08 #4
Hey guys u wudnt believe how long ive searched the internet to find a solution to this... id say it approaching around 12hrs over a week ...

Your help is much appreciated and that coding works perfectly exactly wat i was looking for ... cheers.

I think im gona have to help a few ppl on this wen i finish my coursework to balance it out a bit :)
Sep 5 '08 #5
RamananKalirajan
608 512MB
Hey guys u wudnt believe how long ive searched the internet to find a solution to this... id say it approaching around 12hrs over a week ...

Your help is much appreciated and that coding works perfectly exactly wat i was looking for ... cheers.

I think im gona have to help a few ppl on this wen i finish my coursework to balance it out a bit :)

I am realy happy that you got the required thing. There is some difference between mine and the other expert who posted another link. Mine is Dom, the expert what he had given is using innerHTML. Understanding innerHTML is very easy. In future any doubts post it in the forum. I will be there trying to help u out.

Regards
Ramanan Kalirajan
Sep 5 '08 #6

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

Similar topics

3
by: Michael Gruner | last post by:
Hi, is there any idea about creating column names dynamically within a select statement and without stored procedures? We have some tables that have column names that consist of chars and...
8
by: Tom | last post by:
I've a problem. I want to clone an object having a list of other objects (and so on :/). Do you know any other way than ICloneable.Clone() implementation for all classes in the way? Help..
3
by: AVL | last post by:
Hi, I've a query in cloning. How cloning is different from creating a new instance of an object.? I suppose cloning also creates a new object and copies the exisitng object's data. Where and when...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
3
by: Coleen | last post by:
Hi all :-) I have a datatable that I need to clone completely except for 1 column - I need to replace the contents of this 1 column with the contents from another datatable that has the exact...
6
by: cefrancke | last post by:
I've read up on Access and the limits of creating visible controls at run-time. I'm using Access 2003 and assume that it cant be done. I did find a clever method of having a main form (and in...
3
by: finleeds | last post by:
hi all I m using the visual studio designer to create 1 Dataset with 1 table with 3 columns : Id, Name, Birthday. Once this done, still with the designer, I m creating a datagridview and...
3
by: raylopez99 | last post by:
The "C# Cookbook" (O'Reilly / Jay Hilyard), section 3.26, is on deep cloning versus shallow cloning. The scanned pages of this book are found here: http://www.sendspace.com/file/mjyocg (Word...
15
by: mark.norgate | last post by:
Hello I want to create a reference to an object, so that changes to the referenced object are reflected in the other object. Like this: object o = 123; object p = o; o = 456;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.