By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,569 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,569 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.