Link to home
Start Free TrialLog in
Avatar of arjang070898
arjang070898

asked on

resubmitting a form based on input from another window

I have a script that prints out a html page.  The user will input values and then submit the form. If certain criteria is not met, a pop-up window is then opened and the user must select a radio button and send that value back the originating page. Now the originating page(the script) must be re-run with the value from the pop-up window and all the calculations must be re-done.  I pass the value of the radio button the first page through a hidden field but when I re-submit the page, all the user-entered values are gone and the hidden-field value is undefined.  How do I keep the values there while re-calculating with the value submitted from the pop-up window ????

Here is some of the code for the script:
#!/usr/local/bin/perl

require 'header.pl';
require 'msc.pl';
require 'timelocal.pl';


&header("FAX-PRQ","Purchaser Pre-Qualification","faxprq");
&ReadPost(*inputs);

# PAT
$percent = 0;
$errmsg = "";

if ($inputs{"Submit"})
{
#OTHER CALCULATIONS DONE HERE

  $ceiling = $inputs{"test"};
  if ($percent <= 5)
  { if ($ceiling == 0)
    { $errmsg .= "You must select a Home Price Ceiling for your area.<br>";

# THIS IS WHERE I OPEN THE POP-UP WINDOW IF IT IS NEEDED
      print '<SCRIPT LANGUAGE="Javascript">',"\n";
    print 'window.open("/help/ceiling.html", "Ceiling_Price_List", "scrollbars=yes,width=450,height=300");',"\n";
    print "</SCRIPT>\n";
      $was_below_five = 1;  
      $highest = 0;
    }  

print "<FORM NAME=Form1 action=",$CGI_BIN,"/prq.pl method=POST>\n";

#THIS IS THE HIDDEN FIELD
print "<INPUT TYPE=TEXT NAME=test VALUE=$ceiling>\n";

print "<P><TABLE BORDER=0 cellpadding=3><tr bgcolor=#eee5ca>\n";

#TEXT FIELDS WHERE USER INPUTS INFO
print "<tr bgcolor=#eee5ca>\n";
print "<td colspan=6>";
print '<input type=submit name=Submit value="Calculate Qualification">',"\n";
print '<input type=submit value="Clear Form">',"\n";
print "</table>\n";
print "</FORM>\n";
print "</CENTER>\n";

This is the code for the pop-up window:

<HTML><HEAD>
<TITLE>Home Price Ceiling List</TITLE>
<SCRIPT LANGUAGE="Javascript">
function byebye()
{  window.close();
}
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF" text="#000000">
<FORM METHOD=POST onSubmit="opener.document.Form1.test.value = this.rb.value;byebye();opener.document.Form1.submit();">
<P><FONT SIZE=2>Since your down payment was 5% or less than the purchase price, you will
need to choose a ceiling that applies to your area.  To select, click on the button with the Code
number associated with your area and click on Send.</FONT>
<TABLE>
<TR><TH>Municipality</TH>
<TH>Ceiling</TH>
<TH>Code</TH>
<TD COLSPAN=2></TD>
<TH COLSPAN=3>Press Price Ceiling Code</TH></TR>
<TR><TD>Metro Toronto(All)</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD><TD COLSPAN=2></TD>
<TD ALIGN="CENTER"><INPUT TYPE=RADIO NAME=rb VALUE=1>1</TD>
<TD ALIGN="CENTER"><INPUT TYPE=RADIO NAME=rb VALUE=2>2</TD>
<TD ALIGN="CENTER"><INPUT TYPE=RADIO NAME=rb VALUE=3>3</TD></TR>
<TR><TD>Peel Region(All)</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD>
<TD COLSPAN=3></TD><TD ALIGN="CENTER"><INPUT TYPE=SUBMIT NAME=Submit VALUE="Send"></TD></TR>
<TR><TD>York Region(All)</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD></TR>
<TR><TD>Halton Hills</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD></TR>
<TR><TD>Milton, Oakville</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD></TR>
<TR><TD>Ajax, Pickering</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD></TR>
<TR><TD>Scugog, Uxbridge</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD></TR>
<TR><TD>Orangeville</TD><TD>$250,000</TD><TD ALIGN="CENTER">1</TD></TR>
<TR><TD>Oshawa</TD><TD>$175,000</TD><TD ALIGN="CENTER">2</TD></TR>
<TR><TD>Hamilton</TD><TD>$175,000</TD><TD ALIGN="CENTER">2</TD></TR>
<TR><TD>Barrie</TD><TD>$175,000</TD><TD ALIGN="CENTER">2</TD></TR>
<TR><TD>Most Other Centres</TD><TD>$125,000</TD><TD ALIGN="CENTER">3</TD></TR>
</TABLE></FORM></BODY></HTML>
ASKER CERTIFIED SOLUTION
Avatar of alamo
alamo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sybe
sybe

onClick="opener.document.Form1.test.value=3"
will only work when you open the popup with something like:
PopUp = window.open("/help/ceiling.html", "Ceiling_Price_List", "scrollbars=yes,width=450,height=300"

This makes it possible to refer back to the opener
Ok, yes, but that's how the popup *is* opened in the arjang's example script... I'm not sure I see your point.
alamo: the point is that you can't link back to the opener when it is not a variable in the original document.
Sorry, you have lost me... are you saying assigning the value of window.open to a variable (PopUp in your example) is necessary? It works fine without it in Netscape and IE. The variable is only necessary when referring to the popup from the main page, not when referring to the main page from the popup.

arjang's original code worked perfectly in both NS and IE when it came to setting the value in the main form from the popup. The value was wrong, but it was was being passed properly to the main form..