[prev in list] [next in list] [prev in thread] [next in thread]
List: cgi-list
Subject: [CGI] [Off topic] Using JS, transferring data between windows
From: "Penn White" <pwhite () surfsouth ! com>
Date: 1998-07-26 3:12:56
[Download RAW message or body]
Hi all,
I've posted this question to 2 javascript newsgroups, 2 javascript listservs and on \
javascripts.com and gotten no responses at all. I'm hoping that some javascript guru \
out there in cgi land will read this message and take pity on me. I apologize in \
advance for the off-topic posting, especially to those people who are paying by the \
kb for messages. If it really rankles your craw, just post a message to the effect \
that 'these #@$%!! off-topic postings really p*** me off', and I'll never ever do it \
again. ;-)
TIA,
Penn White
****** Beginning of Message ******
I am trying to write a javascript that opens a new window, performs calculations on \
the incoming data and then sends the result back to the opener window. The new \
window calculates the total square yards of a fabric needed based upon the length and \
width entered by the user. Problem is, there are several fabrics to choose from and \
I need the calculation window to recognize which fabric is being used so that the \
result returns to the proper (square yardage required) field in the opener page.
I'm sure that is totally confusing so I've put a sample of what I'm doing below. \
What I am currently trying (which isn't working) is to use a hidden field to signal \
which text input box the result should go in but it only works the first time and \
only for the first selection. I've tried lots of different things and nothing is \
working. I'm so confounded at the moment that I don't know where to start over \
anymore.
It's actually a bit more complicated than this and there are several checks to make \
sure that fields aren't empty or don't contain characters other than numbers, etc., \
but this is the part I'm having trouble with. (note: for the 'good eyes' folks, the \
yardage area is divided by 8 to get the total square yards rather than by 9 to allow \
some additional fabric for wastage :-))
*** opener window script ***
...<script language="javascript">
<!-- begin cloaking
function winOpen(openURL)
{calcWindow = window.open(openURL,"Calculate Yardage", "height=350 width=450");}
// end cloaking -->
</script>
<body>
<input type="hidden" name="item" value=1>
<a href="javascript:winOpen('calcYdg.htm')">Calculate Yardage</a>
<INPUT TYPE="text" NAME="yardsNeeded1" SIZE="5" MAXLENGTH="5" >
<input type="hidden" name="item" value=2>
<a href="javascript:winOpen('calcYdg.htm')">Calculate Yardage</a>
<INPUT TYPE="text" NAME="yardsNeeded2" SIZE="5" MAXLENGTH="5" >
</body>...
*** calculate yardage window (calcYdg.htm) ***
...<script language="javascript">
<!-- begin cloaking
function compute() {
var totalSqYds =
(document.forms[0].length.value)*(document.forms[0].width.value);
var yardsNeeded = totalSqYds/8;
if (window.opener.document.forms[0].item.value = 1) {
yardsNeeded1=yardsNeeded;
} else if (window.opener.document.forms[0].item.value = 2) {
yardsNeeded2=yardsNeeded;
}
window.opener.document.forms[0].yardsNeeded1.value=yardsNeeded1;
window.opener.document.forms[0].yardsNeeded2.value=yardsNeeded2;
}
// end cloaking -->
</script>
<body>
<center>
<form>
<table border=0 align="center">
<tr>
<td><strong>room:</strong></td>
<td>length</td>
<td><input type="text" name="length" size="5" maxlength="5" ></td>
<td>width</td>
<td><input type="text" name="width" size="5" maxlength="5" ></td>
</tr>
</table>
<table border=0 cellpadding=2 align="center">
<td><input type="reset" value="RESET"></td>
<td><input type="button" value="COMPUTE YARDAGE" onclick="compute()"></td>
<td><input type="button" value="CANCEL"
onclick="javascript:window.close()"></td>
</table>
</form>
</center>
</body>...
[Attachment #3 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META content='"MSHTML 4.72.3110.7"' name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000000 size=2>Hi all,</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>I've posted this question to 2 javascript
newsgroups, 2 javascript </FONT><FONT color=#000000 size=2>listservs and on
javascripts.com and gotten no responses at all. I'm </FONT><FONT
color=#000000 size=2>hoping that some javascript guru out there in cgi land will
read this </FONT><FONT color=#000000 size=2>message and take pity on me. I
apologize in advance for the off-topic </FONT><FONT color=#000000
size=2>posting, especially to those people who are paying by the kb for
messages. If it really rankles your craw, just post a message to the
effect that 'these #@$%!! off-topic postings really p*** me off', and I'll never
ever do it again. ;-)</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>TIA,</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>Penn White</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>****** Beginning of Message ******</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT> </DIV>
<DIV><FONT color=#000000 size=2>I am trying to write a javascript that opens a
new window, performs </FONT><FONT color=#000000 size=2>calculations on the
incoming data and then sends the result back </FONT><FONT color=#000000
size=2>to the opener window. The new window calculates the total square
</FONT><FONT color=#000000 size=2>yards of a </FONT><FONT color=#000000
size=2>fabric needed based upon the length and width entered by </FONT><FONT
color=#000000 size=2>the user. Problem is, there are several fabrics to
choose from and I </FONT><FONT color=#000000 size=2>need the calculation window
to recognize which fabric is being used </FONT><FONT color=#000000 size=2>so
that </FONT><FONT color=#000000 size=2>the result returns to the proper (square
yardage required) field </FONT><FONT color=#000000 size=2>in the opener
page.<BR><BR>I'm sure that is totally confusing so I've put a sample of what I'm
doing below. What I am currently trying (which isn't working) is to use a
hidden field to signal which text input box the result should go in but it only
works the first time and only for the first selection. I've tried lots of
different things and nothing is working. I'm so confounded at the
</FONT><FONT color=#000000 size=2>moment that I don't know where to start over
anymore.<BR><BR>It's actually a bit more complicated than this and there are
several checks to make sure that fields aren't empty or don't contain characters
other than numbers, etc., but this is the part I'm having trouble with. (note:
for the 'good eyes' folks, the yardage area is divided by </FONT><FONT
color=#000000 size=2>8 to get the total square yards rather than by 9 to allow
some additional fabric for wastage :-))<BR><BR>*** opener window script
***<BR><BR>...<script language="javascript"><BR><!--
begin cloaking<BR>function winOpen(openURL)<BR> {calcWindow =
window.open(openURL,"Calculate Yardage", "height=350
width=450");}<BR>// end cloaking
--><BR></script><BR><body><BR> <input
type="hidden" name="item" value=1><BR>
<a href="javascript:winOpen('calcYdg.htm')">Calculate
Yardage</a><BR> <INPUT TYPE="text"
NAME="yardsNeeded1" SIZE="5" MAXLENGTH="5"
><BR><BR> <input type="hidden"
name="item" value=2><BR> <a
href="javascript:winOpen('calcYdg.htm')">Calculate
Yardage</a><BR> <INPUT TYPE="text"
NAME="yardsNeeded2" SIZE="5" MAXLENGTH="5"
><BR><BR></body>...<BR><BR>*** calculate yardage window (calcYdg.htm)
***<BR><BR>...<script
language="javascript"><BR><BR><!-- begin cloaking<BR>function
compute() {<BR> var totalSqYds
=<BR>(document.forms[0].length.value)*(document.forms[0].width.value);<BR>
var yardsNeeded = totalSqYds/8;<BR> if
(window.opener.document.forms[0].item.value = 1) {<BR>
yardsNeeded1=yardsNeeded;<BR> } else if
(window.opener.document.forms[0].item.value = 2) {<BR>
yardsNeeded2=yardsNeeded;<BR> }<BR>
window.opener.document.forms[0].yardsNeeded1.value=yardsNeeded1;<BR>
window.opener.document.forms[0].yardsNeeded2.value=yardsNeeded2;<BR>}<BR>// end
cloaking
--><BR></script><BR><body><BR><center><BR><form><BR><table \
border=0
align="center"><BR><tr><BR><td><strong>room:</strong></td><BR><td>length</td><BR><td><input \
type="text" name="length" size="5"
maxlength="5"
></td><BR><td>width</td><BR><td><input
type="text" name="width" size="5"
maxlength="5"
></td><BR></tr><BR></table><BR><table border=0
cellpadding=2 align="center"><BR><td><input
type="reset"
value="RESET"></td><BR><td><input
type="button" value="COMPUTE YARDAGE"
onclick="compute()"></td><BR><td><input
type="button"
value="CANCEL"<BR>onclick="javascript:window.close()"></td&g \
t;<BR></table><BR></form><BR></center><BR></body>...</FONT></DIV></BODY></HTML>
-----------------------------------------------------------------
For subscription information, http://www.jann.com/
The CGI Tips & Tricks website (and archive of the list) is located
at http://www.jann.com/Perl/
cgi-list is hosted by Summit Communication Design (http://www.summitdesign.net).
-----------------------------------------------------------------
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic