Code Snippets

  

ColdFusion Source Code


Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,105 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,128 people online right now. Registration is fast and FREE... Join Now!





IsChecked Function

Check to see if a radio button or check box should be checked when editing data. Passes the value of the radio button and the data for that field and returns "checked" or nothing.

Submitted By: supersloth
Actions:
Rating:
Views: 5,095

Language: ColdFusion

Last Modified: May 10, 2005
Instructions: See comments for instructions.

Snippet


  1. <!--- This function is used when loading data in to a form for editing purposes
  2. there is often a need to check the radiobutton that was selected. Pass the stored
  3. value (data) and compares it to the value (value) of that radio button.    --->
  4.  
  5.      <cffunction name="isChecked">
  6.           <cfargument name="data" required="yes" default="0">
  7.         <cfargument name="value" required="yes" default="1">
  8.          
  9.           <!--- Clear the variable in case the function remains stateful --->
  10.         <cfset checkedTag="">
  11.      
  12.         <cfif arguments.data is arguments.value>
  13.                  <cfset checkedTag="checked">
  14.           </cfif>
  15.      
  16.         <cfreturn checkedTag />
  17.      </cffunction>
  18.      
  19. <!---
  20. Implementation:
  21. <input type="radio" name="thisButton" value="SomeValue" #isChecked(data=thedata, value="SomeValue")#>
  22. --->
  23.  
  24.  

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month