/    Sign up×
Community /Pin to ProfileBookmark

document.write using variable.values

Hoping I can get some help. I have been pulling my hair out all weekend on this. All the books say it is done exactly the way I am doing it, but no-go.

I have an HTML file where many radio buttons are clicked, values calculated from this, and then the results displayed.

In the simplest of it, I have them fill in a Project name:

<table cellpadding=”10″ width=”90%”>
<TR><TD width=”15%”><B>Project Name:</B></TD><TD width=”85%”><input type=”TEXT” name=”[B]TopProjectName[/B]” size =”75″ value=””></TD></TR>

After the click of the calculate button, a javascript piece does this:

document.Form1.[B]BottomProjectName.value[/B] = Form1.[B]TopProjectName[/B].value;

then later uses this in a table displayed with the other calculated results:

<TR><TD><B><font size=”+1″>Project Name:</font></B></TD><TD><input type=”TEXT” name=”[B]BottomProjectName[/B]” size=”75″ value=””>

</TD></TR>

Okay… all of this works fine. BUT, what I am trying to do is to display all of the output (as directly above) in a new window using document.write. So… the last thing I do after the calculations, before I would continue and display the info at the bottom of the page, is to call a function full of document.write statements:

function DisplayResults()
{

document.write(‘<center>’);
document.write(‘<H2>Determination of Release Path<BR>for CDP Project</H2>’);
document.write(‘<TABLE border=0 align=center width=”90%”>’);
document.write(‘<TR><TD align=left><img src=”KP_Logo.bmp”></TD><TD align=right><img src=”CDF_Logo.bmp” height=80></TD></TR>’);
document.write(‘</TABLE>’);
document.write(‘</center>’);
document.write(‘<table cellpadding=10>’);

//ONE
//alert(Form1.BottomProjectName.value);

//TWO
var TempString = ” <TR><TD><B>Project Name: </B></TD><TD>” + Form1.BottomProjectName.value + “</TD></TR>”;
//document.write(TempString);

//THREE
//TempString = Form1.BottomProjectName.value;
//document.write(TempString);

//FOUR
document.write(‘ <TR><TD><B><font size=”+1″>Business Partner: </font></B></TD><TD>[B]$BottomBusinessPartner[/B]</TD></TR>’);
document.write(‘ <TR><TD><B><font size=”+1″>Sponsor: </font></B></TD><TD>[B]$BottomSponsor[/B]</TD></TR>’);
document.write(‘ <TR><TD><B>&nbsp;</B></TD><TD>&nbsp;</TD></TR>’);
document.write(‘</Table>’);


Note that, as long as I do not have ONE, TWO or THREE in there, is write the entire thing to a new page, but the [B]$BottomBusinessPartner[/B] and [B]$BottomSponsor[/B] are just placeholders right now, not the value of the variable, which is what I want.

What is displayed in TWO is what should work, according to all of the books. If I use what is in THREE just to test, it prints NOTHING, including anything after that point.

Even if I just use what is in ONE to see what that value should be, it stops printing right there.

Any help on this one? Full code is here, in case you need it (about 1450 lines, this section is at around 930):

[URL=http://www.nehrt.com/IRP/ReleasePath.htm]Code[/URL]

Hoping on getting this finished soon, so I don’t have to use the ugly, in line results I currently have.

Any info is appreciated .

Thx.

Flip

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisMar 17.2003 — You cannot use document.write() on an existing (completed, done loading) document. It will erase everything that is there, and you lose all your objects (forms, vars, etc).

You can use document.write() inside a layer (div, span, etc) because it is insulated from the surrounding document. You can also open a new window and use document.write() on it without destroying the original document. In newer browsers you can use innerHTML to replace portions of the document without opening the document and erasing essential data.
Copy linkTweet thisAlerts:
@fnehrtauthorMar 17.2003 — What I am trying to do is to create a new page, using the information gathered/calculated from the current page. You are saying that as soon as I do a [B]document.write[/B] I wipe out all of the information I have gathered or calculated. How would I use a DIV to avoid this, or how would I send all of this information to the next html page to be displayed? Not too handy with FORMs and or DIVs.

THx.

Flip
Copy linkTweet thisAlerts:
@gil_davisMar 18.2003 — [i]Originally posted by fnehrt [/i]

[B]What I am trying to do is to create a new page, using the information gathered/calculated from the current page.[/B][/QUOTE]
You can use the ACTION of the form to pass the information to a new page through the URL. See http://developer.netscape.com/viewsource/goodman_url_pass/goodman_url_pass.html for an example.

Or open a new window and use document.write() on the new window.var newWin = window.open();
newWin.document.write(...);
...
newWin.document.close();
Copy linkTweet thisAlerts:
@fnehrtauthorMar 18.2003 — That was IT!! The New Window. Had created a second frame, but was clumsy. With the change of about 3 lines, your method was up and working.

Beautiful!

Thanks.

Flip
×

Success!

Help @fnehrt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...