[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>&nbsp;</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.&nbsp; 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.&nbsp; 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.&nbsp; 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>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2>TIA,</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2>Penn White</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2>****** Beginning of Message ******</FONT></DIV>
<DIV><FONT color=#000000 size=2></FONT>&nbsp;</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.&nbsp; 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.&nbsp; 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.&nbsp; 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.&nbsp; I've tried lots of 
different things and nothing is working.&nbsp; 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>...&lt;script&nbsp; language=&quot;javascript&quot;&gt;<BR>&lt;!-- 
begin cloaking<BR>function winOpen(openURL)<BR>&nbsp;&nbsp;&nbsp; {calcWindow = 
window.open(openURL,&quot;Calculate Yardage&quot;, &quot;height=350 
width=450&quot;);}<BR>// end cloaking 
--&gt;<BR>&lt;/script&gt;<BR>&lt;body&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input 
type=&quot;hidden&quot; name=&quot;item&quot; value=1&gt;<BR>&nbsp;&nbsp;&nbsp; 
&lt;a href=&quot;javascript:winOpen('calcYdg.htm')&quot;&gt;Calculate 
Yardage&lt;/a&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;INPUT TYPE=&quot;text&quot; 
NAME=&quot;yardsNeeded1&quot; SIZE=&quot;5&quot; MAXLENGTH=&quot;5&quot; 
&gt;<BR><BR>&nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; 
name=&quot;item&quot; value=2&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;a 
href=&quot;javascript:winOpen('calcYdg.htm')&quot;&gt;Calculate 
Yardage&lt;/a&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;INPUT TYPE=&quot;text&quot; 
NAME=&quot;yardsNeeded2&quot; SIZE=&quot;5&quot; MAXLENGTH=&quot;5&quot; 
&gt;<BR><BR>&lt;/body&gt;...<BR><BR>*** calculate yardage window (calcYdg.htm) 
***<BR><BR>...&lt;script&nbsp; 
language=&quot;javascript&quot;&gt;<BR><BR>&lt;!-- begin cloaking<BR>function 
compute() {<BR>&nbsp; var totalSqYds 
=<BR>(document.forms[0].length.value)*(document.forms[0].width.value);<BR>&nbsp; 
var yardsNeeded = totalSqYds/8;<BR>&nbsp; if&nbsp; 
(window.opener.document.forms[0].item.value = 1) {<BR>&nbsp;&nbsp;&nbsp; 
yardsNeeded1=yardsNeeded;<BR>&nbsp; } else if&nbsp; 
(window.opener.document.forms[0].item.value = 2) {<BR>&nbsp;&nbsp;&nbsp; 
yardsNeeded2=yardsNeeded;<BR>&nbsp; }<BR>&nbsp; 
window.opener.document.forms[0].yardsNeeded1.value=yardsNeeded1;<BR>&nbsp; 
window.opener.document.forms[0].yardsNeeded2.value=yardsNeeded2;<BR>}<BR>// end 
cloaking 
--&gt;<BR>&lt;/script&gt;<BR>&lt;body&gt;<BR>&lt;center&gt;<BR>&lt;form&gt;<BR>&lt;table \
 border=0 
align=&quot;center&quot;&gt;<BR>&lt;tr&gt;<BR>&lt;td&gt;&lt;strong&gt;room:&lt;/strong&gt;&lt;/td&gt;<BR>&lt;td&gt;length&lt;/td&gt;<BR>&lt;td&gt;&lt;input \
 type=&quot;text&quot; name=&quot;length&quot; size=&quot;5&quot; 
maxlength=&quot;5&quot; 
&gt;&lt;/td&gt;<BR>&lt;td&gt;width&lt;/td&gt;<BR>&lt;td&gt;&lt;input 
type=&quot;text&quot; name=&quot;width&quot; size=&quot;5&quot; 
maxlength=&quot;5&quot; 
&gt;&lt;/td&gt;<BR>&lt;/tr&gt;<BR>&lt;/table&gt;<BR>&lt;table border=0 
cellpadding=2 align=&quot;center&quot;&gt;<BR>&lt;td&gt;&lt;input 
type=&quot;reset&quot;&nbsp; 
value=&quot;RESET&quot;&gt;&lt;/td&gt;<BR>&lt;td&gt;&lt;input 
type=&quot;button&quot; value=&quot;COMPUTE YARDAGE&quot; 
onclick=&quot;compute()&quot;&gt;&lt;/td&gt;<BR>&lt;td&gt;&lt;input 
type=&quot;button&quot; 
value=&quot;CANCEL&quot;<BR>onclick=&quot;javascript:window.close()&quot;&gt;&lt;/td&g \
t;<BR>&lt;/table&gt;<BR>&lt;/form&gt;<BR>&lt;/center&gt;<BR>&lt;/body&gt;...</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