dynamically populating cfwindow

I have some code that gets data from a database. I want to create a link that when the user click on it for more information to change the cfwindow contents dynamically based on the record selected. in the ColdFusion.window.show method, you can't pass in parameters. Any ideas?
Who is Participating?
SidFishesConnect With a Mentor Commented:
this should give you an idea

<cfajaximport tags="cfwindow"></cfajaximport>
function showWin(){
	var d = new Date();
	var wid = d.getMinutes()+d.getSeconds(); 		
	ColdFusion.Window.create("myWindow"+wid, showWin.arguments[0], "msgWindow.cfm?msg=" + showWin.arguments[1], {height:400,width:400,modal:true,closable:true, draggable:false,resizable:false,center:true,initshow:true,refreshOnShow:true});
	ColdFusion.objectCache["myWindow"+wid] = null;	
<button onclick="showWin('Apples', 'Granny Smith');">Apples</button>
<button onclick="showWin('Oranges', 'Valencia');">Oranges</button>

Open in new window

btw, we use the wid variables and clear objectCache to prevent caching issues with the window once it is closed and reopened

oh... and the msWindow.cfm file code is simply

<span style="font-size:.8em;font-family:tahoma;">

you could also put query code in here to provide info based on an ID passed in the url.msg rather than trying to pass it all in the url variable
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

just call ColdFusion.navigate() function before ColdFusion.Window.show() function.

azadisaryevConnect With a Mentor Commented:
i think i need to elaborate a bit more:

say, your db output is like this:

<a href="##" onclick="showDetails(#ID#)">#Name#</a>

each db record has a unique id that you pass to showDetails() js function, which in turn looks like this:

showDetails = function(id){
  ColdFusion.navigate('someurl.cfm?id='+id, 'detailsWindow');

stick that function in a <script> block in the HEAD section of your page.

then all you need to do is add a <cfwindow> tag at the bottom of your page with name='detailsWindow' and initshow="false" and NO source attribute (any other attributes can be whatever you need them to be)

that's all.

asaworkerAuthor Commented:
Thats everyone. This is eactly what I wa slooking for. azadisaryev, that is how I did do it, but I needed to chnage bthe title of the cfwindow dynamically too like what SidFishes said. I also have more than one window to open on each page.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.