473,394 Members | 1,642 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,394 software developers and data experts.

set ids for fields in new row created

hi,
i have a button that creates a new row on each button click.The row has textboxes ,dropdown lists etc whose value is passed onto another ajax function.My problem is that i am not able to set a unique id like test#i# to all the fields in each row created.This is the function used to create the new rows.
[HTML]<SCRIPT LANGUAGE="JavaScript">


function addRow(id)

{

var tbody = document.getElementById(id).getElementsByTagName(" TBODY")[0];

var row = document.createElement("TR");
var td1 = document.createElement("TD");

td1.innerHTML='<label><input type="checkbox" name="Datum#i#" value="1"></label>';
var oldHTML = document.getElementById('test').innerHTML

var td2 = document.createElement("TD");
td2.innerHTML=oldHTML;

var td3 = document.createElement("TD");
var oldHTML1=document.getElementById('test1').innerHTM L
td3.innerHTML=oldHTML1;

var td4 = document.createElement("TD");
var oldHTML2=document.getElementById('test2').innerHTM L
td4.innerHTML=oldHTML2;

var td5 = document.createElement("TD");
var oldHTML3=document.getElementById('test3').innerHTM L
td5.innerHTML=oldHTML3;

var td6 = document.createElement("TD");
var oldHTML4=document.getElementById('test4').innerHTM L
td6.innerHTML=oldHTML4;

var td7 = document.createElement("TD");
var oldHTML5=document.getElementById('test5').innerHTM L
td7.innerHTML=oldHTML5;

var td8 = document.createElement("TD");
var oldHTML6=document.getElementById('test6').innerHTM L
td8.innerHTML=oldHTML6;


row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
row.appendChild(td5);
row.appendChild(td6);
row.appendChild(td7);
row.appendChild(td8);
tbody.appendChild(row);

}

</script>[/HTML]
please let me know how i can set the ids of all the fields created when a new row is created.'id' passed to the function is the table id.
Mar 12 '08 #1
3 1451
acoder
16,027 Expert Mod 8TB
Use the id property of each cell. If you have a variable "i" that is the new number to add, then just use something like "test"+i. Remember though that an id must be unique within the page.
Mar 13 '08 #2
Use the id property of each cell. If you have a variable "i" that is the new number to add, then just use something like "test"+i. Remember though that an id must be unique within the page.
thank you..that helped :)
Mar 14 '08 #3
acoder
16,027 Expert Mod 8TB
Glad it did! Post again should you have any more questions.
Mar 14 '08 #4

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

Similar topics

1
by: Grim Reaper | last post by:
I asked this question, earlier, and received an answer that I am not sure about how to do. Basically, I am printing mailing labels with a "Sorting/Grouping" section that groups the label types...
36
by: No Spam | last post by:
Dear fellow Access 2003 Users, Is there a way to trim all of the fields in a table in one swoop using VBA (preferred) or a query? Right now, I am using an update query and updating EACH field...
4
by: Stone Chen | last post by:
Hello, I have form that uses javascript createElement to add additional input fields to it. However, my validating script will not process new input fields because it can only find the named...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
3
by: shawnews | last post by:
Please help me...a newbie here.... I having been working two days on a project, thought I was almost done until I tried to create a report using a query I had succesfully made. I get an error...
3
by: guido | last post by:
I've written a user control to add form fields to a aspx page: Private Sub buildFields() 'Label1.Text = "building fields at " & System.DateTime.Now() Dim themeIDField As New TextBox()...
0
by: daverskully | last post by:
I have two tables created and want to link two forms created from these tables so that specific fields are populated once one field is selected, but not all fields being populated, with a new record...
2
by: daverskully | last post by:
I have two tables created and want to link two forms created from these tables so that specific fields are populated once one field is selected, but not all fields being populated, with a new record...
8
by: zyzolus | last post by:
Hello, I create 2 unique indexes on 2 fields: Field1 and Field2. What is the way generate custom error message independent of each field?ex.: "Duplicate value in Field1" or "Duplicate value...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.