Solved

Cfform post to cfwindow

Posted on 2008-06-17
2
1,483 Views
Last Modified: 2013-12-24
Hi,

I have a search results page that displays a list of products that the user can add to a shopping cart.

I want a cfwindow to appear and display the contents of the shopping cart when the cfform submits.

Is there a way to target the window in the cfform tag?

Almost like so:



<cfform name="AddToBasket" action="#Application.WebRoot#/shoppingbasket/basket.cfm?ServiceType=AC" method="post" target="cfWindowName">

Open in new window

0
Comment
Question by:TIO-Solutions
2 Comments
 
LVL 36

Accepted Solution

by:
SidFishes earned 125 total points
Comment Utility
I put this together a couple of weeks ago....it's a little more complex than what you are asking for but it should give you an idea of what is possible.
 
This snippet provides a cfwindow which scrolls with the page. I developed this for a shopping cart.
It allows customers to see what's in their cart while scrolling on long shopping pages.
Requires an additional file called windowContent.cfm (see commented section in head)

The original rePositionWindow set the vertical position on load and then stopped. By using the
setInterval function in windowContent.cfm, we call rePositionWindow every 1 second. Since rePositionWindow
finds the current Window Element object relative to the viewport, we can apply myWindow.moveTo(X,Y) and it will
also be relative to the viewport. The rest is just getting the window to show and hide as required.

In the example I pass a url variable on creation of the window to get cart information.
The cfwindow would allow you to delete items from the cart via an ajax call (shown as alert()'s in the example
Because of the setInterval call we are not able to offer any input boxes as these lose focus every second, which
makes entry impossible. For my purposes, delete via ajax is fine.

This has been tested in FF3, IE7 and Safari 3.11 (for pc)

see http://www.danvega.org/blog/index.cfm/2008/3/7/Adding-Custom-Buttons-to-ltcfwindowgt for adding buttons to cfwindow
see http://www.coldfusionguy.com/ColdFusion/blog/index.cfm/2008/4/22/Reposition-A-CFWindow--From-Center
for original rePositionWindow function

important:must include the button.js src to access addButton

note: this does not detect browser resolution ...I expect it wouldn't be that hard to dynamically set the moveTo(X,Y) but I didn't go that far. If your site is set for a specific min width, hard coding the values should be fine... (the example is for w=1024)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<!--- 
 
 
 

---- windowContent.cfm ---

<cfoutput>

<script type="text/javascript">

var showCfWin = #url.showCfWin#

if(showCfWin==true){

	setInterval("rePositionWindow('detail')",1000);

	}

</script>

<h3>CartID: #url.vCartID#</h3>
 

<button onclick="alert('Deleted Itemid1');">X</button> Item 1<br>

<button onclick="alert('Deleted Itemid2');">X</button> Item 2<br>

<button onclick="alert('Deleted Itemid3');">X</button> Item 3<BR> 

</cfoutput> 

--------------------------
 

--->

	

<script type="text/javascript" src="http://10.10.10.225/CFIDE/scripts/ajax/ext/package/button/button.js"></script>
 

<script language="JavaScript">

var showCfWin = true

function init(){

	//called from ajaxonload

		myWindow = ColdFusion.Window.getWindowObject('detail');

		myWindow.addButton({

		text:"Hide Cart",

		cls:"x-btn-text-icon",

		handler:hideWin         

      })

    }

    

function hideWin()

	{

		myWindow = ColdFusion.Window.getWindowObject('detail');

		myWindow.moveTo(910,205);

		myWindow.hide()

		showCfWin = false

	}

	

	function showWin()

	{	

		showCfWin=true;

		myWindow = ColdFusion.Window.getWindowObject('detail');

		 ///hide so first appearance doesn't cause flashing'

	    myWindow.hide();

	    myWindow.moveTo(910,205);

	    myWindow.show();

	}

	

   rePositionWindow = function(windowName){

   //Get window object    

   myWindow = ColdFusion.Window.getWindowObject(windowName);

   ///hide so appearance doesn't cause flashing'

   myWindow.hide();

   myWindow.center();

   //get the Window Element object    

   winEl = myWindow.getEl();

   if (showCfWin==false){

   myWindow.moveTo(910,205);

   myWindow.hide();

   }

   else{

   	myWindow.hide();

   myWindow.moveTo(910,205);

   myWindow.show();

   }

   }

</script> 

</head>
 

<bodY>

<div style="display:block;width:1100px;border:1px dashed;height:190px;padding:10px;">

<h1>Welcome to our store</h1>

This is our lovely banner. 

</div>

<div style="width:1100px;">

<div style="float:right;width:198px;border:1px dashed;text-align:center;height:2000px;">

<button onClick="showWin();">Show Cart</button>

</div>
 

<div style="height:2000px;width:898px;display:block;border:1px dashed;padding:25px;">

	

<h2>Roving Cart</h2>
 

</div>

</div>

<cfset vCartID = left(createuuid(), 10)>

<cfwindow closable="true" initShow="false" name="detail" title ="Your Cart"

			source="windowContent.cfm?vcartid=#vCartID#&showCfWin=true"

			Width="190"	

			height="300"

			y="225"	

			x="910"

			>

</cfwindow>	

 <cfset ajaxonload("init")>

</bodY>

</html>

Open in new window

0
 

Author Comment

by:TIO-Solutions
Comment Utility
Thanks for your help, that did give me a good idea of what can be done, and given me an idea of how to improve our current basket.

I have attached the solution our developer came up with as well. It works quite well if you want to do a simple post to a cfwindow.

<cfinput type="image" src="#Application.WebRoot#/images/website/addtobasket.gif" name="Submit" value="Add to my Basket" style="border:0px; padding-bottom:10px;" onClick="ColdFusion.Window.show('MessageWindow');javascript:ColdFusion.navigate('#Application.WebRoot#/travelbasket/travelbasket.cfm?ServiceType=AC','MessageWindow','','','POST','test');">

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now