TechnicallyChris.com

Technical and Personal Ramblings of a Bostonian
  • Home
  • About Chris
  • Donate
  • Contact Chris
Home > ColdFusion > Remember Your Flash Form Tab

Remember Your Flash Form Tab

September 6th, 2006
Goto comments Leave a comment

If you have a flash form with tabs that submits to itself, something you might like to add to your user interface is having the last tab the user was viewing come back by default, instead of the first. I’ve described the way I have done this in the past below.

Step 1: You’ll need to come up with a variable to define which tab the form should load. You should do this before the form loads, it should be a form variable, and you’ll need to use CFPARAM to set it so that it gets reset when the form submits. For this example, we’re going to use iTabIndex. It’s important to know that the tab indexes are zero-based, meaning the first tab is 0, the second tab is 1, and so on.

1
<cfparam name="form.iTabIndex" default="0" type="integer">

Step 2: Next, we’ll need to change the tab when the form loads. There are a few ways to do this, but I’m still using CFSAVECONTENT. Before the form starts, I’d great this using:

2
3
4
<cfsavecontent variable="frmOnLoad">
 grpTabMain.selectedIndex = <cfoutput>#form.iTabIndex#</cfoutput>;
</cfsavecontent>

The name of the variable, frmOnLoad, can be virtually anything, but grpTabMain needs to be the name of the id of the TabNavigator, as we’ll go over in step 4.

Step 3: Next, we’ll have to setup the form so that, upon loading, it selects the tab that we desire. We can do this using the onLoad event of the form. The variable we add here needs to be the name of the variable we created in the previous step.

5
<cfform name="frmExample" method="post" format="flash" onload="#frmOnLoad#">

Step 4: You need to add an ID to your TabNavigator. This is as simple as adding an ID parameter to your CFFORMGROUP, like so:

6
<cfformgroup type="tabnavigator" id="grpTabMain">

And finally, step 5: You need to setup your tabIndex field so that it always contains the current tabIndex for when the form is submitted. This is easier than you think, and can be done just by adding a hidden field inside your form:

7
<cfinput name="iTabIndex" type="hidden" bind="{grpTabMain.selectedIndex}">

And there you have it, you now have a form that, when submitted to itself, will select the tab that was last open.

If you enjoyed this article or it helped you in any way, I’d appreciate it if you’d post a comment below to let me know. All code examples are for demonstration only and should be used at your own risk. I cannot accept liability for unexpected results.

Chris ColdFusion ColdFusion, Flash

Comments (0) Trackbacks (0) Leave a comment Trackback
  1. No comments yet.
  1. No trackbacks yet.
Subscribe to comments feed
Getting the Current ColdFusion Query Row Randomly Replace Words
RSS feed
  • Google
  • Youdao
  • Xian Guo
  • Zhua Xia
  • My Yahoo!
  • newsgator
  • Bloglines
  • iNezha

Sponsored By

Recent Posts

  • Just Bought the Google Nexus One
  • Seven Things I’ve Liked About Windows 7 in Seven Day
  • What’s Happened to Customer Service (Part 2)?
  • What’s Happened to Customer Service (Part 1)?
  • Capturing S.M.A.R.T. Hard Disk Data from WMI with AutoIt
  • Adjusting DCOM Settings via Script
  • How to Manually Call the Google Cache
  • RoboForm & RoboForm2Go Product Review
  • Updated PingCell Function for Excel
  • Creating Hyperlinks in Word and Excel Longer than 256 Characters

Categories

  • ColdFusion
  • Firefox
  • Google Nexus One
  • IIS
  • McAfee EE / SafeBoot
  • Microsoft Windows
  • Oracle
  • Random Code
  • Random Technology
  • Sports and Recreation
  • Subversion
  • The Untechnological

Archives

  • January 2010
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • October 2007
  • September 2007
  • August 2007
  • January 2007
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006

Meta

  • Register
  • Log in
PageRank
Top WordPress
Copyright © 2006-2010 TechnicallyChris.com
Theme by mg12. Valid XHTML 1.1 and CSS 3.