...

View Full Version : Cancel button in popup window "unchecks" option in opener(parent)???



FastCougar
03-15-2004, 04:00 PM
I have a form with a checkbox on page 1 that when checked, opens a popup window with a second optional portion of the form. Let's call this page 2. On page 2, the form can be filled out or it can be canceled. If the cancel button is pressed, it calls a third page, which clears some session variables (coldfusion) and then closes the window. However, back on page 1, the checkbox is still selected. How would I get the script that closes the popup window to uncheck the checked box? I have tried the following, but it doesn't work.
<script type="text/javascript">
<!--
parent.opener.document.frmPickup.COD.checked == false;
window.close();
//-->
</script>

Roy Sinclair
03-15-2004, 04:22 PM
Close, so very, very close.



<script type="text/javascript">
<!--
window.opener.document.frmPickup.COD.checked == false;
window.close();
//-->
</script>

FastCougar
03-15-2004, 04:40 PM
That's not working :(

The window closes successfully, but the form checkbox remains checked. I rearranged how some functions where called, so to recap, here is the important code:

Page 1 = had the form with the following checkbox and JS function:
<input type="checkbox" name="COD" value="yes" onClick="CODPage();"<cfif form.COD eq "yes"> checked</cfif>> and then there is the function that is called with the box is checked:
function CODPage() {
if (document.frmPickup.COD.checked == true) {
centerWindow('step3_cod.cfm', 'cod_request', '520', '380', 'no', 'no');
}
}

Page 2 = has a 2nd part of the first form that uses ColdFusion session variables. When the form is canceled, the variables are cleared from the session scope and the window is closed. The following code SHOULD uncheck the checkbox, but doesn't.Here is the button that calls the function:
<input type="button" value="Cancel COD" onClick="CancelCOD();"> Now, the function:
function CancelCOD() {
<cflock scope="session" type="exclusive" timeout="10">
<cfset StructDelete(session, "CODCompany")>
<cfset StructDelete(session, "CODContact")>
<cfset StructDelete(session, "CODCountry")>
<cfset StructDelete(session, "CODAddress1")>
<cfset StructDelete(session, "CODAddress2")>
<cfset StructDelete(session, "CODCity")>
<cfset StructDelete(session, "CODState")>
<cfset StructDelete(session, "CODZip")>
<cfset StructDelete(session, "CODAmount")>
<cfset StructDelete(session, "CODCheck")>
</cflock>
window.opener.document.frmPickup.COD.checked == false;
self.close();
}I thought that my problem stemmed from the fact that the "form.COD" value hasn't changed from "Yes". So, I removed the "cfif" statement and retried and still the same result. Any ideas?

Roy Sinclair
03-15-2004, 05:03 PM
The Cold Fusion code is just confusing this issue, what's needed is the actual html and javascript that Cold Fusion output to the browser, then you can see how the form looks in html and therefore how it should be referenced by the javascript in the popup window.

FastCougar
03-15-2004, 05:16 PM
I took care of that ... now the popup window function does this:
function CancelCOD() {
window.opener.document.frmPickup.COD.checked == false;
location.href="step3_cod_close.cfm";
}The page that is called, step3_cod_close.cfm clears the session scope variables and then in the body tag I have
onload="window.close;"and it works perfectly. However, the original popup code to uncheck the box isn't working.

Roy Sinclair
03-15-2004, 07:06 PM
Try adding this debug line to see if it triggers:



if (window.opener == null) alert('Opener reference no longer available');

FastCougar
03-15-2004, 07:57 PM
Originally posted by Roy Sinclair
Try adding this debug line to see if it triggers:



if (window.opener == null) alert('Opener reference no longer available');
Tried that and it's not triggering. I have coldfusion debugging on and the values are getting passed to the form. Like I said earlier, I think this all revolves around the fact that I am outputting the values on the form based on what has been passed to the page in the form scope. So, I would need to pass a hidden form input to the page from the popup window called "form.COD" with a value OTHER THAN "yes" since the page code looks like this:
<input type="checkbox" name="COD" value="yes" onClick="CODPage();"<cfif form.COD eq "yes"> checked</cfif>>How would I get JS to submit information back to the page in the form scope???

glenngv
03-16-2004, 02:37 AM
You should have used = not == to make assignment not conditional.

function CancelCOD() {
window.opener.document.frmPickup.COD.checked = false;
location.href="step3_cod_close.cfm";
}

FastCougar
03-16-2004, 04:45 PM
Originally posted by glenngv
You should have used = not == to make assignment not conditional.

function CancelCOD() {
window.opener.document.frmPickup.COD.checked = false;
location.href="step3_cod_close.cfm";
} Worked like a charm ... THANKS!!!!

<slap self upside head>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum