Archive

Archive for November, 2009

cfautosuggest is cool

November 24, 2009 ppshein Leave a comment

I was crazy over GMail when I saw auto suggest function. That’s why I’ve used that features most of my projects, referring from http://script.aculo.us. If I use javascript coding from it, we need to do some changes for our projects.If you’re not well-expert in javascript, you can’t do anything for it. Upset..?? Don’t worry. You can use cfautosuggest. Volià..!!

<cfform action=”autosuggest.cfm” method=”post”>
Name:<br />
<cfinput type=”text” name=”contactname” size=”50″ autosuggest=”cfc:autosuggest.findContact({cfautosuggestvalue})” autosuggestminlength=”1″ maxresultsdisplayed=”10″ /><br /><br />
</cfform>

autosuggest.cfc

<cfcomponent output=”false”>

<!— Lookup used for auto suggest —>
<cffunction name=”findContact” access=”remote” returntype=”string”>
<cfargument name=”search” type=”any” required=”false” default=”">

<!— Define variables —>
<cfset var local = {} />

<!— Query Location Table —>
<cfquery name=”QryAutoSuggestSimple” datasource=”cfexample” >
select        contactname
from        contacts
where        contactname like <cfqueryparam cfsqltype=”cf_sql_varchar” value=”#ucase(arguments.search)#%” />
order by    contactname
</cfquery>

<!— And return it as a List —>
<cfreturn valueList(QryAutoSuggestSimple.contactname)>
</cffunction>

</cfcomponent>

Categories: coldfusion Tags: ,

Coldfusion Force Download

November 16, 2009 ppshein Leave a comment

Don’t you wanna display image file on client browsers when users downloading? It’s kinda simple, use following code :

 

<cfheader name=”Content-Type” value=”unknown”>
<cfheader name=”Content-Disposition” value=”attachment; filename=FileName.jpg”>
<cfcontent type=”Application/Unknown” file=”/http//downloads/FileName.jpg” deletefile=”No”>

Cfwindow

November 13, 2009 ppshein Leave a comment

I’ve read some good information from www.coldfusionjedi.com. I found that’s just like jQuery Dialog box. It has a lot of built-in functions like draggable, resizeable and so on. I’m now testing on it. That’s why I don’t have much of explanation about cfwindow. Check it out for example from

 

http://www.coldfusionjedi.com/index.cfm/2007/6/20/ColdFusion-8-AJAX-UI-Windows

 

setInterval Javascript

November 13, 2009 ppshein Leave a comment

Like gmail, you can use auto fresh your page with setInterval funtion of javascript.

<script>
<!–
intervalID = window.setInterval(“alert(‘Hi’)”,  1000);
–>
</script>

Cflayout

November 13, 2009 ppshein Leave a comment

I didn’t notice cflayout tag is just like DIV before. It’s not much different between cflayout and DIV. Sometimes, it just like iframe. But, we should know this tag will be useful for future. Here is example for cflayout.

 

<html>
<head>
<script type=”text/javascript” charset=’utf-8′>
function CF_RunContent(src){
setTimeout(function(){document.getElementById(‘Center’).innerHTML = src;},5);
}
</script>
</head>
<body>
<a href=”#” onclick=”ColdFusion.navigate(‘mybio.cfm’,'Center’);”>Bio</a>
<cflayout type=”border” name=”layoutborder”>
<cflayoutarea name=”Center” position=”top” style=”width:500px;height:200px” maxSize=”200″>
Welcome
</cflayoutarea>
</cflayout>

</body>
</html>

Crop image proportionally with PHP

November 6, 2009 ppshein Leave a comment

First of all, I’m not PHP geek. But, PHP is my second expert language after CF. I’ve created some freelance projects with PHP . You can hire me if you have some freelance projects for low cost and full reliable.

When I surf website for cropping image, I found this site. It’s cool. Check it out.

http://deepliquid.com/projects/Jcrop/demos/crop.php

Categories: php Tags: , ,

Coldfuion Report Builder

November 6, 2009 ppshein Leave a comment

Of the most powerful and convenient report builder is Coldfusion Report Builder. It’s absolutely just like crystal report. You can make your report design in CF report builder or you can use their built-in theme, either. Are you getting sick of writing query in cf report builder? It’s ok. You can write Query in your cfm file and output report just like :

<cfquery name=”qryUsers” datasource=”#application.datasource#”>
SELECT * FROM Users WHERE U_ID = <cfqueryparam value=”#url.id#” cfsqltype=”CF_SQL_NUMBER”>
</cfquery>

<cfreport template=”NewColdFusionReport.cfr” query=”qryUsers” format=”PDF”>
</cfreport>

CFQUERYPARAM and Oracle Databases

November 5, 2009 ppshein Leave a comment

I’ve already shown in my old posts about the benefit of using cfqueryparam tag. Using this tag can prevent SQL inject and output data format what SQL like.

Generally, we use old-fashioned style like

<CFQUERY DATASOURCE=”DSN_NAME”>
SELECT username
FROM users
WHERE user_id=#SESSION.USER_ID#
</CFQUERY>

In modern style, we use cfqueryparam tag within cfquery tag like

 

<CFQUERY DATASOURCE=”DSN_NAME”>
SELECT username
FROM users
WHERE user_id=<cfqueryparam value=”#SESSION.USER_ID#” cfsqltype=”cf_sql_number”>
</CFQUERY>

 

It’s ok for passing variable is integer. If we want to pass string variable, we need to do following code. Unlike old-fashioned style, we don’t need to put single quote in front of and end of cfqueryparam tag.

 

<CFQUERY DATASOURCE=”DSN_NAME”>
SELECT username
FROM users
WHERE user_name=<cfqueryparam value=”#SESSION.USER_NAME#” cfsqltype=”cf_sql_varchar”>
</CFQUERY>

 

Buch..!! How about Like condition..?? Don’t worry. You can use as follow:

<CFQUERY DATASOURCE=”DSN_NAME”>
SELECT username
FROM users
WHERE user_name=<cfqueryparam value=”%#SESSION.USER_NAME#%” cfsqltype=”cf_sql_varchar”>
</CFQUERY>

Categories: MSSQL, coldfusion Tags: , ,

Check mouse pointer location

November 2, 2009 ppshein Leave a comment

Do you want to check your mouse pointer location? It’s kinda simple. Check it out.

 

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>Browser Coordinate Computation Demo</title>
<script type=”text/javascript”>
function move(e)
{
if (!e) e= event;
var docX,docY;

if (e.pageX == null)
{
// IE case
var d= (document.documentElement &&
document.documentElement.scrollLeft != null) ?
document.documentElement : document.body;
docX= e.clientX + d.scrollLeft;
docY= e.clientY + d.scrollTop;
}
else
{
// all other browsers
docX= e.pageX;
docY= e.pageY;
}

var coord= document.getElementById(‘coord’);
while (coord.firstChild) coord.removeChild(coord.firstChild);
coord.appendChild(document.createTextNode(docX+’,'+docY));

var xhair= document.getElementById(‘crosshair’);
xhair.style.left= docX-8+’px’;
xhair.style.top= docY-8+’px’;

return false;
}

if (document.addEventListener)
{
document.addEventListener(“mousedown”,move, false);
}
else if (document.attachEvent)
{
document.attachEvent(“onmousedown”,move);
}
</script>
</head>
<body>
<h3>Click to Move Crosshairs</h3>
Shrink screen so you can get scroll bars and test this in a scrolled window.
<p>
X,Y=(<span id=”coord”>?,?</span>);
<img id=”crosshair” src=”crosshair.gif” style=”position: absolute; left: 90px; top: 150px”>

<p>&nbsp; <p>&nbsp; <p>&nbsp; <p>&nbsp;<p>
<pre>
if (e.pageX == null)
{
// IE case
var d= (document.documentElement &&
document.documentElement.scrollLeft != null) ?
document.documentElement : document.body;
docX= e.clientX + d.scrollLeft;
docY= e.clientY + d.scrollTop;
}
else
{
// all other browsers
docX= e.pageX;
docY= e.pageY;
}
</pre>
</body>
</html>

 

Best credit : http://unixpapa.com/js/mouse.html