Copy link to clipboard
Copied
Hi,
Is there a way to pass parameters to a cfwindow?
If yes, please provide me with all relevant details.
HERE IS MY SITUATION:
I have a form, in which I'm looping over a recordset e.g.
<cfform name="frmTest">
<cfset counter = 0>
<cfloop query="variables.qTest">
<cfset counter = variables.counter + 1>
<cfinput
type="checkbox"
name="test_#variables.counter#_ch"
onClick="showPopUp(#variables.qTest.id#,#variables.qTest.amount#)">
</cfloop>
</cfform>
Here is my javascript / ajax:
<script type="text/javascript">
<!--
function showPopUp(id,amt){
ColdFusion.Window.show("approvalWindow");
}
//-->
</script>
And here is my cfwindow:
<cfwindow
name="approvalWindow" center="true" closable="true"
draggable="false" modal="true" title="Approval"
initshow="false" width="680" height="315">
HOW CAN I OBTAIN THE VALUES OF id AND amt HERE?
E.g.
<cfset idClicked = id>
<cfset amtClicked = amt>
I'll be needing those 2 variables for further processing...
</cfwindow>
I know I could have used a simple javascript window.open and passed those 2 parameters in the URL scope, but, I don't want my users to see what id I'm sending.
Thanks and regards,
Yogesh Mahadnac.
Copy link to clipboard
Copied
Hi,
Please try this,
<script language="javascript">
function ShowCfWindow(id,amt)
{
ColdFusion.Window.create('Window1', 'Window Title','test.cfm?test='+ id,
{_cf_refreshOnShow:true,x:100,y:100,height:300,width:400,modal:false
,closable:true,draggable:true
,resizable:true,center:true
,initshow:true,minheight:200,minwidth:200 });
}
</script>
Copy link to clipboard
Copied
Hi,
Many thanks for your answer.
It actually works under "static" conditions, i.e. if I'm calling the cfwindow inside a cfloop, the value of ID is not refreshed.
Let me show you what I mean.
For example, here is my form
<cfform name="frmTest">
<cfset counter = 0>
<cfloop query="variables.qTest">
<cfset counter = variables.counter + 1>
<cfinput
type="checkbox"
name="test_#variables.counter#_ch"
onClick="showPopUp(#variables.qTest.id#,#variables.qTest.amount#)">
</cfloop>
</cfform>
This gives the output, e.g.
Checkbox 1 | Checkbox 2 | Checkbox 3 | Checkbox 4 | Checkbox 5 |
---|---|---|---|---|
ID 1 | ID 2 | ID 3 | ID 4 | ID 5 |
showPopUp(1,10) | showPopUp(2,15) | showPopUp(3,12) | showPopUp(4,15) | showPopUp(5,50) |
Now, here is the showPopUp part (using the solution you provided to me):
<cfajaximport tags="cfwindow">
<script type="text/javascript">
<!--
function showPopUp(id,amt){
ColdFusion.Window.create('Window1','Window Title','test.cfm?ID='+ id + '&amt=' + amt,
{_cf_refreshOnShow:true,height:290,width:630,modal:true,closable:true,draggable:true,resizable:false,center:true,initshow:true});
}
//-->
</script>
And then on test.cfm, we can easily obtain the value of ID and amt using the url scope
<cfset id = url.ID>
<cfset amt = url.amt>
<cfdump var="#url#" label="Checking values sent from checkbox">
Normally, the value of ID should be 1, 2, 3, 4 or 5 depending on the checkbox you click, right?
When you click the 1st one, ID 1 is sent in the url (this is fine).
However, if you click the 3rd checkbox after having clicked the 1st one, the value of ID and amt still reflect that of the 1st checkbox.
It is not "refreshed" to 3 and 12, you still get ID = 1 and amt = 10.
Is there anything we missed in the showPopUp script?
Thanks and regards,
Yogesh Mahadnac.
Copy link to clipboard
Copied
Hi,
Any help on this issue would be most welcome.
At the moment, I'm only using Javascript window.open and passing the parameters in the URL.
The cfwindow solution would be most appropriate.
Thanks and regards,
Yogesh Mahadnac.
Copy link to clipboard
Copied
try this
<script language="javascript">
function viewPopUp(idVal)
{
myWindow=window.open('file2.cfm?id='+idVal,'file2','width=400,height=400')
}
</script>
Copy link to clipboard
Copied
Hi,
Many thanks for your answer.
However, I'm currently looking for the cfwindow answer, not the Javascript solution.
Rest assured, I do know that the JS solution works - this is what I'm currently using - but the aim of this thread was to find out a new type of solution using CF & Ajax.
If you refer to the explanations I've given in the thread, at the moment, when using the cfwindow, the values are not refreshing.
Normally, inside the loop, the values are dynamic - 1, 2, 3, 4, 5, etc.
If I click on the 1st checkbox, the value should be 1, 2nd checkbox - value 2, etc.
With the cfwindow, if I click on the 1st checkbox, the value on the window that pops-up is 1 - fine.
Now, if you click on the 2nd checkbox AFTER you have clicked on the 1st one, the value on the popup window is STILL 1, not 2.
It is because of this problem that I've posted this thread.
You may try out the example that I've given in the thread to help you understand.
Hope it's clearer so that you may better assess the situation and provide a possible solution.
Thanks and regards,
Yogesh
Copy link to clipboard
Copied
I'm not sure why javascript wouldn't work for you? The fact that you are pushing values from a checkboxes is a little different.
Have you looked at this article http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_u-z_3.html ? The bottom examples should help you out with this method.
Copy link to clipboard
Copied
Hi Drew!
Many thanks for your reply.
Quote from my last thread (in reply to Dileep):
"Rest assured, I do know that the JS solution works - this is what I'm currently using - but the aim of this thread was to find out a new type of solution using CF & Ajax."
Thanks and regards,
Yogesh.