473,791 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding a Row to Parent Table is not working

In my script

<script language="javas cript">
function AddItinerary()
{
var newRow;
var newCell1,newCel l2,newCell3,new Cell4,newCell5, newCell6;

newRow = document.create Element("tr");
newCell1 = document.create Element("td");
newCell2 = document.create Element("td");
newCell3 = document.create Element("td");
newCell4 = document.create Element("td");
newCell5 = document.create Element("td");
newCell6 = document.create Element("td");

var depdate = AirItineraryFor m.DepDate_TextB oxID.value + " " +
AirItineraryFor m.cmbDepHH + ":" + AirItineraryFor m.cmbDepMM;
var arrdate = AirItineraryFor m.ArrDate_TextB oxID.value + " " +
AirItineraryFor m.cmbArrHH + ":" + AirItineraryFor m.cmbArrMM;

newCell1.innerH TML = "<span
style=\"color:# 003366;font-family:Trebuche t MS;font-size:X-Small;\">"
+ AirItineraryFor m.txtDepFrom.va lue + "</span>";
newCell2.innerH TML = "<span
style=\"color:# 003366;font-family:Trebuche t MS;font-size:X-Small;\">"
+ AirItineraryFor m.txtDesig.valu e + "</span>";
newCell3.innerH TML = "<span
style=\"color:# 003366;font-family:Trebuche t MS;font-size:X-Small;\">"
+ depdate + "</span>";
newCell4.innerH TML = "<span
style=\"color:# 003366;font-family:Trebuche t MS;font-size:X-Small;\">"
+ arrdate + "</span>";
newCell5.innerH TML = "<span
style=\"color:# 003366;font-family:Trebuche t MS;font-size:X-Small;\">"
+ AirItineraryFor m.txtClass.valu e + "</span>";
newCell6.innerH TML = "<span
style=\"color:# 003366;font-family:Trebuche t MS;font-size:X-Small;\">"
+ AirItineraryFor m.txtFlight.val ue + "</span>";

newRow.appendCh ild(newCell1);
newRow.appendCh ild(newCell2);
newRow.appendCh ild(newCell3);
newRow.appendCh ild(newCell4);
newRow.appendCh ild(newCell5);
newRow.appendCh ild(newCell6);
/*************** *************** *************** *************** **/
alert("About to add"); // upto this it is working
/*************** *************** *************** *************** **/
/* Not Working after this line */
/*************** *************** *************** *************** ***
window.opener.t blAirTravel.fir stChild.appendC hild(newRow);
alert("Added to Table");
return true;
}

What i have to do to add a row dynamically to the table in the parent
window?

Thanks in Advance
John.
Jul 23 '05 #1
4 3628


John wrote:

window.opener.t blAirTravel.fir stChild.appendC hild(newRow);


Well first of all you seem to want to insert your table rows created in
one window into a table in another window. That works with Mozilla but
the DOM requires you to import such nodes and for instance Opera 7
requires that. And with IE/Win the whole thing is not possible at all,
there you need
newRow = window.opener.d ocument.createE lement('tr');
There might be other problems, from what you show above it is not clear
what tblAirTravel is, what its firstChild is. You should normally append
rows to a tbody or thead or tfooot element, in particular IE requires
that. And for Mozilla you probably need
window.opener.d ocument.getElem entById('tblAir Travel')
but all that is guessing, you need provide more information.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen wrote:
[...]
There might be other problems, from what you show above it is not clear
what tblAirTravel is, what its firstChild is. You should normally append
rows to a tbody or thead or tfooot element, in particular IE requires
that.

[...]

Good point, particularly "what its firstChild is". The general way is
to use the rows collection to find the row you want to add the new one
after, then use insertBefore and nextSibling.

If there is no nextSibling (i.e. you want to add it after the last
row), then that is what happens.

It's also worth noting that rows can't be parents (or children) of
other rows. So even if firstChild was a row, and indeed another was
added as a child, the results would be unreliable at best.

If you want to just toss the row in the general direction of the table
and let the browser work out how to add it, then use appendChild on the
table itself, this adds it to the end of the table body reasonably
reliably.

Fred.
Jul 23 '05 #3
Martin Honnen wrote:
[...]
There might be other problems, from what you show above it is not clear
what tblAirTravel is, what its firstChild is.

[...]

Good point, particularly "what its firstChild is". The general way is
to use the rows collection to find the row you want to add the new one
after, then use insertBefore and nextSibling.

If there is no nextSibling (i.e. you want to add it after the last
row), then that is what happens.

It's also worth noting that rows can't be parents (or children) of
other rows. So even if firstChild was a row, and indeed another was
added as a child, the results would be unreliable at best.

If you want to just toss the row in the general direction of the table
and let the browser work out how to add it, then use appendChild on the
table itself, this adds it to the end of the table body reasonably
reliably.

Rob.
Jul 23 '05 #4


Fred Oz wrote:

If you want to just toss the row in the general direction of the table
and let the browser work out how to add it, then use appendChild on the
table itself, this adds it to the end of the table body reasonably
reliably.


No, at least with MSIE/Win you need to make sure you call appendChild on
a tbody (or thead or tfoot) element, if you call appendChild on a table
itself passing in a row as the argument IE doesn't render the row at all
so what you suggest above is not a good suggestion, the leading browser
in terms of market share doesn't "work out how to add it".

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #5

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

Similar topics

7
2958
by: Ilan Sebba | last post by:
I am trying to add a record using SQL. My problem is that the primary keys are foreign keys, and these foreign keys are autonumbers. I therefore do not know the primary keys of the record I am trying to insert. I therefore do not think that I can use the sql "Insert Into" command. Here is a simplified illustration of my tables: tblFather NaturalKey1 NatuarlKey2
1
1568
by: Steve Leferve | last post by:
Hey folks I'm working on a 'duplicate' function. I need to duplicate related child records in the same subtable. Two questions: 1. My 'db.execute' function is not working. How can I trouble shoot it? The SQL insert syntax looks okay. However, the records don't go in. There is no error message.
4
5483
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
20
2150
by: Bryan | last post by:
hello all... im trying to add a record to an sql db on ms sql server 2000, using vb.net. seems to be working.. except for one thing, one of the columns in the database is a bit datatype, and though i get no syntax errors when compiling, i get an error indicated that the data would be truncated. the field is login_status. ive tried in quotes and not, giving it an integer variable with the number 1
16
2490
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill it with incremental values e.g. if the tables looks like this: 23 56
15
3132
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an OnSelectedIndex event is not fired if you select the first item. Does anyone know of an easy way to do this?
7
2013
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on subform(to frmInvoices) sfrmDetails via qryDetails. Relationship built between tblClients/tblInvoices/tblDetails by ClientID. Relationship between tblInvoices/tblDetails by InvoiceID. All works fine if
4
2551
by: Rob Meade | last post by:
Hi all, I played with my first bit of AJAX the other week and was pleasantly surprised that I achieved my goal..now I'd like to try something else.. Question... If I have an updatePanel, and lets say I have a button as a trigger which runs a function in my code behind to add a textbox to the updatePanel, when the form is submitted does this control actually "exist" as such on the
3
18720
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
0
9669
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10427
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5431
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.