473,550 Members | 2,975 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with DOM

I have a script which adds a row. I am using the DOM model to do this.
I have an image link which is to be inserted next to a input field in
each row i add , how do i do this?

I think i have to change the "TD" elemement somehow , also my code
has to work in netscape. Has anybody got a solution to this :

<head>
<script type="text/javascript">
function addRow(id){

var index = document.form1. hidden.value;
var tbody = document.getEle mentById(id).ge tElementsByTagN ame("TBODY")[0];
var row = document.create Element("TR");
row.setAttribut e("id","row" + index);
//Clone this node
var targetNode = document.getEle mentById('SELEC T')
input1 = targetNode.clon eNode(true)
input1.setAttri bute("name","se lect" +index)

input2 = document.create Element("input" );
input2.setAttri bute("name","a" +index)
input2.setAttri bute("value","" )
input2.setAttri bute("type","te xt")
input2.setAttri bute("readOnly" ,"false")
input2.setAttri bute("size","32 ")

input3 = document.create Element("input" );
input3.setAttri bute("name","b" +index)
input3.setAttri bute("value","" )
input3.setAttri bute("type","te xt")
input3.setAttri bute("readOnly" ,"false")
input3.setAttri bute("size","8" )

input4 = document.create Element("input" );
input4.setAttri bute("name","c" +index)
input4.setAttri bute("value","" )
input4.setAttri bute("type","te xt")
input4.setAttri bute("readOnly" ,"false")
input4.setAttri bute("size","5" )

input5 = document.create Element("input" );
input5.setAttri bute("name","d" +index)
input5.setAttri bute("value","" )
input5.setAttri bute("type","te xt")
input5.setAttri bute("size","8" )

var td1 = document.create Element("TD")
td1.appendChild (input1)

var td2 = document.create Element("TD")
td2.appendChild (input2)

var td3 = document.create Element("TD")
td3.appendChild (input3)

var td4 = document.create Element("TD")
td4.appendChild (input4)

var td5 = document.create Element("TD")
td5.appendChild (input5)

row.appendChild (td1);
row.appendChild (td2);
row.appendChild (td3);
row.appendChild (td4);
row.appendChild (td5);
tbody.appendChi ld(row);

//increase index of hidden field
index++
document.form1. hidden.value=in dex
}
</script>
</head>

<body>
<form name="form1">
<input type="hidden" value="0" name="hidden">
<table id="myTable" cellspacing="0" border="1">
<tr>
<td>&nbsp;<sele ct size="1" name="havnkode" id="select">
<option value="02">Drop down</option>
<option value="00">Test 1</option>
<option value="28">Test 2</option>
<option value="06">Test 3</option>
</td>
<td>row1_column 1</td><td>row1_col umn1</td><td>
</tr>
</table>
<input type="button" value="new row"
onClick="javasc ript:addRow('my Table')">
</form>
</body>
</html>
Jul 20 '05 #1
1 3201


spaminator wrote:
I have a script which adds a row. I am using the DOM model to do this.
I have an image link which is to be inserted next to a input field in
each row i add , how do i do this?

I think i have to change the "TD" elemement somehow , also my code
has to work in netscape. Has anybody got a solution to this :


//create the link
var link = document.create Element('a');
//set href
link.href = 'whatever.html' ;
// create img element
var img = document.create Element('img');
img.src = 'whatever.gif';
img.alt = 'whatever';
//append img to link
link.appendChil d(img);
//append link to table cell
cell.appendChil d(link);

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2412
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its last year we got traffic of between 2000 - 2500 unique visitors per day. We are now about to re-launch the site from Sweden and we need to purchase a...
7
4375
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a few features that you'd expect in any editor, except nearly none of them seem to have: 1 - Search and repalce with Regular Expressions. 2 - ...
15
3662
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit cumbersome to always include std. I somewhere found a trick to overcome this problem. By using using std::cout;
9
2913
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with a device. The definition of the table is as follows: CREATE TABLE devicedata ( device_id int NOT NULL REFERENCES devices(id), -- id in the...
3
2605
by: Bob.Henkel | last post by:
I write this to tell you why we won't use postgresql even though we wish we could at a large company. Don't get me wrong I love postgresql in many ways and for many reasons , but fact is fact. If you need more detail I can be glad to prove all my points. Our goal is to make logical systems. We don't want php,perl, or c++ making all the...
3
10617
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays...
4
7387
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is there are multiple pages per invoice. How can I grab the data, make the TIF, place it on the client and then Open with the clients default program...
8
1820
by: Sai Kit Tong | last post by:
In the article, the description for "Modiy DLL That Contains Consumers That Use Managed Code and DLL Exports or Managed Entry Points" suggests the creation of the class ManagedWrapper. If I need to build multiple mixed mode dll's used by a consumer application, do I have to implement multiple ManagedWrapper's (each embedded in indiviudal...
2
1939
by: Michael R. Pierotti | last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$") Dim m As Match = reg.Match(txtIPAddress.Text) If m.Success Then 'No need to do anything here Else MessageBox.Show("You need to enter a valid IP Address", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Hand) txtIPAddress.Focus() Return End If
0
3924
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need Inbox Reply from Craig Somerford <uscos@2barter.net> hide details 10:25 pm (3 minutes ago)
0
7561
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7488
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7761
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7520
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6101
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3532
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1978
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1094
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
801
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.