ColdFusion Tips and Tutorials

ColdFusion Tips and Tutorials. Tips on ColdFusion, AJAX, CSS, JavaScript, HTML, Design, and more.

CFUnited Developer Conference 2010
Use this code TIPSCUST to get $100 off your registration @ CFUnited! We'll see you There!


ColdFusion Tips
Page 1 2 3
8 Web Design Policies: Implement | Email A
7 cfif | DataSource List | Design | cfnewb
6 Test for File | Test for Variable
5 ODBC DateTime | Spread Sheet | Alleged N
4 Last Updated Footer | Display a list of
3 Beginner | cftree
2 Dynamic Table | Date-Time-Number Format
1 Output Text in X Rows | GreenBar Effect
Page 1 2 3



Custom Search
=============================================================
COLDFUSION TIPS PLUS Volume 00 Issue 16
=============================================================

I. My Comments:

II. ColdFusion Tip: 2D Array Sorting

III. Website: webos.org CF Site

IV. Quick Tip: Cntrl - N and cntrl - Tab


=============================================================
I. My Comments:

All Future e-ZINES will be saved in the member area
of my website. I am creating a cf portal for
all of us.

If you have suggestions please email me at cftips @nsnd.com.
Remove the Space to make it work correctly


=============================================================
II. ColdFusion Tip: 2D Array Sorting
=============================================================

<cfapplication sessionmanagement="Yes" name="Test">

<cfset x1="3, 4, 22, 2">
<cfset x2="16, 3, 35, 67">
<cfset x3="43, 45, 68, 62">
<cfset x4="78, 63, 30, 23">
<cfset x5="26, 23, 27, 6">
<cfset x6="11, 84, 74, 43">

<CFSET myArray = ArrayNew(2)>

<cfoutput>

<cfloop from="1" to="4" index="z">

<cfset myArray[1][z]= #ListGetAt(x1,z)#>
<cfset myArray[2][z]= #ListGetAt(x2,z)#>
<cfset myArray[3][z]= #ListGetAt(x3,z)#>
<cfset myArray[4][z]= #ListGetAt(x4,z)#>
<cfset myArray[5][z]= #ListGetAt(x5,z)#>
<cfset myArray[6][z]= #ListGetAt(x6,z)#>

</cfloop>

</cfoutput>


<html>
<head>
<title>Sorting A 2D Array</title>
</head>

<body bgcolor="ffffff">
<center>
<font face="Arial,Helvetica,sans-serif" size="-1" color="000000">
Pick Which Row to Sort
</font>
</center>
<cfparam name="url.row" default="2">
<cfif #url.row# gt 4>
<cfset row=3>
<cfelse>
<cfset row=#url.row#>
</cfif>

<cfoutput>
<table align="center" border="1" bordercolor="006699"
cellpadding="0" cellspacing="0" width="500">

<tr bgcolor="006699">

<td>
<font face="Arial,Helvetica,sans-serif" size="-1" color="FFFFFF">
<b>Before</b></
font>
</td>
</tr>
<tr bgcolor="dddddd">

<td>
<font face="Arial,Helvetica,sans-serif" size="-1" color="000000">
Sort Row
<a href="sorting_a_3d_array.cfm?row=1">1</a> |
<a href="sorting_a_3d_array.cfm?row=2">2</a> |
<a href="sorting_a_3d_array.cfm?row=3">3</a> |
<a href="sorting_a_3d_array.cfm?row=4">4</a>
</font>
</td>
</tr>
<tr>

<td>

<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr bgcolor="dddddd">

<td>#MyArray[1][1]#</td>
<td>#MyArray[1][2]# </td>
<td>#MyArray[1][3]#</td>
<td>#MyArray[1][4]# </td>
</tr>
<tr>

<td>#MyArray[2][1]#</td>
<td> #MyArray[2][2]#</td>
<td>#MyArray[2][3]#</td>
<td>#MyArray[2][4]#</td>
</tr>
<tr bgcolor="dddddd">

<td>#MyArray[3][1]#</td>
<td>#MyArray[3][2]#</td>
<td>#MyArray[3][3]#</td>
<td>#MyArray[3][4]# </td>
</tr>
<tr>

<td>#MyArray[4][1]#</td>
<td> #MyArray[4][2]#</td>
<td>#MyArray[4][3]#</td>
<td>#MyArray[4][4]# </td>
</tr>
<tr bgcolor="dddddd">

<td>#MyArray[5][1]# </td>
<td>#MyArray[5][2]#</td>
<td> #MyArray[5][3]# </td>
<td>#MyArray[5][4]# </td>
</tr>
<tr>

<td>#MyArray[6][1]#</td>
<td>#MyArray[6][2]#</td>
<td> #MyArray[6][3]#</td>
<td>#MyArray[6][4]# </td>
</tr>
</table>


</td>
</tr>
</table>
</cfoutput>
<!--- Now Do the Sorting. --->

<cfset session.TotalRecords = 6>
<cfset session.array_name ="myArray">
<!-- BEGIN BUBBLE SORT -->
<cfset outerloopend = session.TotalRecords>
<cfset innerloopend = session.TotalRecords-1>
<cfset innerloopstart = 1>
<cfset temp = 1>

<CFLOOP INDEX="outerloop" FROM="1" TO="#outerloopend#">
<CFLOOP INDEX= "innerloop" FROM="#innerloopstart#" TO="#innerloopend#">
<cfif #myArray[innerloop][row]# gt #myArray[outerloop][row]#>
<CFSET temp = ArraySwap(myArray,outerloop,innerloop)>
</cfif>
</CFLOOP>
</CFLOOP>
<cfoutput>
<table align="center" border="1" bordercolor="006699"
cellpadding="0" cellspacing="0" width="500">

<tr bgcolor="006699">

<td>
<font face="Arial,Helvetica,sans-serif" size="-1" color="FFFFFF"><b>After</b></font>
</td>
</tr>
<tr>

<td>

<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr bgcolor="dddddd">

<td>#MyArray[1][1]#</td>
<td>#MyArray[1][2]# </td>
<td>#MyArray[1][3]#</td>
<td>#MyArray[1][4]# </td>
</tr>
<tr>

<td>#MyArray[2][1]#</td>
<td> #MyArray[2][2]#</td>
<td>#MyArray[2][3]#</td>
<td>#MyArray[2][4]#</td>
</tr>
<tr bgcolor="dddddd">

<td>#MyArray[3][1]#</td>
<td>#MyArray[3][2]#</td>
<td>#MyArray[3][3]#</td>
<td>#MyArray[3][4]# </td>
</tr>
<tr>

<td>#MyArray[4][1]#</td>
<td> #MyArray[4][2]#</td>
<td>#MyArray[4][3]#</td>
<td>#MyArray[4][4]# </td>
</tr>
<tr bgcolor="dddddd">

<td>#MyArray[5][1]# </td>
<td>#MyArray[5][2]#</td>
<td> #MyArray[5][3]# </td>
<td>#MyArray[5][4]# </td>
</tr>
<tr>

<td>#MyArray[6][1]#</td>

<td>#MyArray[6][2]#</td>

<td> #MyArray[6][3]#</td>

<td>#MyArray[6][4]# </td>
</tr>
</table>


</td>
</tr>
</table>
</cfoutput>

<center><a href="../index.cfm">Index</a>
<br>
<hr width="400">
<cfinclude template="../footer.cfm">

</body>
</html>


=============================================================

=============================================================
III. Website: webos.org CF Site
=============================================================

webos.org, webos.com, and Hyperoffice.com

This is what the future will look like Check it out a OS
that runs thru the web. Well at least a simulated OS.

But this one is AWESOME!!!

ps. by the way it was made with ColdFusion!!!

=============================================================
IV. Quick Tip: Cntrl - N and cntrl - Tab
=============================================================

Cntrl-N
Gives you a new document

Cntrl Tab Switches from one document to another open
document.

=============================================================
These Quick Tip are things that the average programmer will
know or I think they will know. Just in case you don't
this is a great place to learn about something that make
your life better.
=============================================================


=============================================================
Copyright (c) 2000 NSND.COM
Permission is granted to circulate this publication via
MANUAL forwarding by email to friends provided that the
text is forwarded in its entirety and no fee is charged.
=============================================================
To unsubscribe:
unsubscribe-cftips @nsnd.com
Remove the Space to make it work correctly
=============================================================
To subscribe:
subscribe-cftips @nsnd.com
Remove the Space to make it work correctly
=============================================================

Photo of Nathan Stanford
Nathan Stanford
LinkedIn

R. Marty Ladner's
Site