473,499 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write rows into pre-formatted table in second window

I want to open a window that has been pre-formatted with a table and
then write rows to the table. The pre-formatted url is named
budget.html and the body looks like this:

<body>
<h1 align="center">Budget for <div id=vertical></div></h1>
<table width="100%" cellpadding="0" cellspacing="0">
<tr style="background-color:#000000;color:#FFFFFF;">
<td width="50%">Parameter</td>
<td width="25%">Site-A</td>
<td width="25%">Site-B</td>
</tr>
</table>
</body>

The javascript I have tried is:

function printList() {
window.open('budget.html','budget','width=1000');
function writerow(name,feet,inches,weight) {
budget.document.write("<tr align='center'>");
budget.document.write("<td>"+name+"</td>");
budget.document.write("<td>"+feet+" foot, "+inches+" inch(es)</
td>");
budget.document.write("<td>"+weight+"Kg</td>");
budget.document.write("</tr>");
}
writerow("Michael Owen","5","7","70");
writerow("Emile Heskey","6","2","150");
writerow("Steven Gerrard","6","0","85");
document.close();
//a.print();
}

This gives a firebug message of "budget has no properties". Why?

Thanks in advance for any assistance.
Jul 24 '08 #1
2 1584
On Jul 24, 4:04*pm, Steve <stephen.jo...@googlemail.comwrote:
I want to open a window that has been pre-formatted with a table and
then write rows to the table. The pre-formatted *url is named
budget.html and the body looks like this:

<body>
<h1 align="center">Budget for <div id=vertical></div></h1>
* <table width="100%" cellpadding="0" cellspacing="0">
* * * * * * * * <tr style="background-color:#000000;color:#FFFFFF;">
* * * * * * * * * * * * <td width="50%">Parameter</td>
* * * * * * * * * * * * <td width="25%">Site-A</td>
* * * * * * * * * * * * <td width="25%">Site-B</td>
* * * * * * * * </tr>
* </table>
*</body>

The javascript I have tried is:

function printList() {
* * * * *window.open('budget.html','budget','width=1000');
* * * * *function writerow(name,feet,inches,weight) {
* * * * * * *budget.document.write("<tr align='center'>");
* * * * * * * * * budget.document.write("<td>"+name+"</td>");
* * * * * * * * * budget.document.write("<td>"+feet+" foot, "+inches+" inch(es)</
td>");
* * * * * * * * * budget.document.write("<td>"+weight+"Kg</td>");
* * * * * * * * * budget.document.write("</tr>");
* * * * *}
* * * * *writerow("Michael Owen","5","7","70");
* * * * *writerow("Emile Heskey","6","2","150");
* * * * *writerow("Steven Gerrard","6","0","85");
* * * * *document.close();
* * * * *//a.print();

}

This gives a firebug message of "budget has no properties". Why?

Thanks in advance for any assistance.
I've never done anything like this before, but I think you need to
give your created window object a variable name.

var budget = window.open('budget.html','budget','width=1000');
Jul 25 '08 #2
Beez wrote:
On Jul 24, 4:04 pm, Steve <stephen.jo...@googlemail.comwrote:
>I want to open a window that has been pre-formatted with a table and
then write rows to the table. The pre-formatted url is named
budget.html and the body looks like this:
[...]
The javascript I have tried is:

function printList() {
window.open('budget.html','budget','width=1000');
function writerow(name,feet,inches,weight) {
budget.document.write("<tr align='center'>");
[...] budget.document.write("<td>"+name+"</td>");
}

This gives a firebug message of "budget has no properties". Why?

Thanks in advance for any assistance.

I've never done anything like this before, but I think you need to
give your created window object a variable name.

var budget = window.open('budget.html','budget','width=1000');
In better words, the window name as specified by the second argument of
window.open() or the `name' property of Window objects have nothing to do
with an identifier in the script.

Instead, the object reference that window.open() returns (if it returns one;
there are popup blockers) must be assigned to a variable or property; this
is _not_ naming the created Window object, it is naming one reference to it.

So this would work as well:

var foo = window.open('budget.html','budget','width=1000');
if (foo)
{
foo.document.write(...);
}
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jul 25 '08 #3

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

Similar topics

3
1496
by: Tom | last post by:
Since the Sony camera saves images with a set name convention, I would like the following program to create an on the fly listing of the images in the directory. Any help is appreciated! <HTML>...
2
3566
by: Mats Mohlin | last post by:
We are runing a critical batchjob in DB2 V8 fp4 for AIX on a p630 with AIX 5.2 The job updates only 6 columns of the 100 columns in a 600 bytes wide row. The job is very IO bound because of log...
6
10035
by: Betty Hickman | last post by:
I'm having trouble writing a 2D array to a binary file. Here's what I have: FILE *outfile; short **clump_class; clump_class = malloc(nrows * sizeof(short *)); for (i=0; i<nrows; ++i)...
2
916
by: Ronchese | last post by:
Hi all. I need to lock my Datagrid so the users cannot add rows using that last row ("*" row). My exact target is make the Datagrid not display that last row to the user, while allowing the...
3
5071
by: Christoffer Gurell | last post by:
After declaring a cursor. Is there any way you can check the number of rows that cursor contains ?? / Christoffer Gurell ---------------------------(end of...
1
3122
by: awebguynow | last post by:
First off, I think the dynarch calendar is quite wonderful, and I've been using it for months. I'm having some issues with form inputs in rows, and initializing the calendar. My fields, and...
3
1230
by: cooltech77 | last post by:
Hi, I have a windows form with a button and a richtext box On click of a button ,I am looping through a datatable which has 3600 rows and i am checking some code for each column in the...
2
2494
by: Satya | last post by:
Hi, I need to read and write Configuration Settings as shown below: <MySettings> <General> <Color>Red</Color> <.Font>TimesNewRoman</Font> <Path>C</Path> </General>
8
2295
by: mohammaditraders | last post by:
#include <iostream.h> #include <stdlib.h> #include <conio.h> #include <string.h> class Matrix { private : int numRows, numCols ; int elements ;
1
2026
by: xiao | last post by:
HI~ guys , I have a program here (Sorry it is very long about 240 lines.) It can read and write the header information successfully but it cannot write the array successfully. I guess there is...
0
7130
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
7007
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...
0
7171
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
7220
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
7386
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
5468
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
4918
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
4599
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
1427
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 ...

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.