Archive

Archive for the ‘Coldfusion’ Category

Unwanted cfscript tag in xmlhttlrequest for cfchart in IE

October 24, 2010 2 comments

I wanted to refresh whole div containing cfchart with updated chart using simple xmlHttpReq. I simply write another .cfm page having new charts with which i replace chart in my calling .cfm page. It worked fine in Firefox n safari, but in can’t see any updated chart in IE, whole

was blank. There was not even any java script error shown. Problem was that IE inserts tag at the top of html code. So all the html beneath that is not displayed in IE. Below code will solve that purpose. All it does is replace any found in the xmlHttp.responseText

xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState == 4 && xmlhttp.status==200)
{
var res = xmlhttp.responseText;
res = res.replace(new RegExp(“[<||\>]”,”gi”),””);
document.getElementById(“charts”).innerHTML = res;
}
}
Categories: Coldfusion

Coldfusion useful tag – cfsavecontent

September 23, 2010 Leave a comment

I found cfsavecontent tag very helpful. There are two cool things about this tag:

1) you don’t have to use ‘&’ (ampersand) to concatenate string anymore. Just put them inside cfsavecontent.

2) you can loop thorough query or any collection object in coldfusion and save the result in one variable. And that variable can be used in many ways especially when you are running an ajax application and want result jason format.

Usage:

<cfsavecontent  variable=”detailTable” > 

<tr style=”font-weight:bold; background-color:#FFFF9B” >

<td width=”11%”><strong>Column1</strong></td>

<td width=”10%”><strong>Column2</strong></td>

<td width=”10%”><strong>Column3</strong></td

<td width=”10%”><strong>Column4</strong></td>

<td width=”10%”><strong>Other</strong></td>

</tr>

<Cfset r1= 0>

<Cfset r2= 0>

<Cfset r3= 0>

<Cfset r4= 0>

<Cfset Other = 0>

<cfloop query=”name_of_query”>

<tr onMouseOver=”this.style.backgroundColor=’##FFFFDD'” onMouseOut=”this.style.backgroundColor=’##FEFEFE'” >

<td><strong>#result1#</strong><Cfset r1= r1+ result1></td>

<td>#result2#<Cfset r2= r2+ result2></td>

<td>#result3#<Cfset r3= r3+ result3></td>

<td>#result4#<Cfset r4=  r4+ result4></td>

<td>#other#<Cfset ot=  ot+ other></td>

</tr>

</cfloop>

</cfsavecontent>

And best part is that you can you variable that you used to add like r1,r2,r3… etc.. in the rest of the coldfusion script.

Design a site like this with WordPress.com
Get started