Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cancel button in popup window "unchecks" option in opener(parent)???

    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.
    Code:
    <script type="text/javascript">
    <!--
    parent.opener.document.frmPickup.COD.checked == false;
    window.close();
    //-->
    </script>

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Close, so very, very close.

    Code:
    <script type="text/javascript">
    <!--
    window.opener.document.frmPickup.COD.checked == false;
    window.close();
    //-->
    </script>
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    <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:
    Code:
    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:
    Code:
    <input type="button" value="Cancel COD" onClick="CancelCOD();">
    Now, the function:
    Code:
    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?
    Last edited by FastCougar; 03-15-2004 at 05:43 PM.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I took care of that ... now the popup window function does this:
    Code:
    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
    Code:
    onload="window.close;"
    and it works perfectly. However, the original popup code to uncheck the box isn't working.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try adding this debug line to see if it triggers:

    Code:
    if (window.opener == null) alert('Opener reference no longer available');
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #7
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Roy Sinclair
    Try adding this debug line to see if it triggers:

    Code:
    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:
    Code:
    <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???

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts

    You were really so close!

    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";
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #9
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: You were really so close!

    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •