ColdFusion Tutorial

Check boxes

A group of related check boxes is created using a series of input tags with the same name. Related check boxes don't need the multiple select fields.

There are several ways to test a group of related check boxes, this is one of them:
Here we first test if any of the check boxes is checked by using 'isDefined'.
Then we find out how many check boxes have been checked by using 'listLen'.
Finely we are testing each check box using 'listContains'.

Example code:

<!--- check_boxes.cfm --->
<form method="post" action="test_check_boxes.cfm">
<input name="fovorite_pet" type="checkbox" value="pig">Pig<br>
<input name="fovorite_pet" type="checkbox" value="bird">Bird<br>
<input name="fovorite_pet" type="checkbox" value="fish">Fish<br>
<input name="fovorite_pet" type="checkbox" value="cat">Cat<br>
<input name="fovorite_pet" type="checkbox" value="dog">Dog <br>
<input name="fovorite_pet" type="checkbox" value="rabbit">Rabbit <br>
<input name="submit_button" type="submit">
</form>

<!--- test_check_boxes.cfm --->
<cfif NOT isDefined("Form.fovorite_pet")>
  No favorite pets are selected.
  <cfelse>
  You have 
  <cfoutput>#listLen(Form.fovorite_pet)#</cfoutput>
  favorite pets, they are:
  <cfif listContains("#Form.fovorite_pet#","pig")>
    Pig
  </cfif>
  <cfif listContains("#Form.fovorite_pet#","bird")>
    Bird
  </cfif>
  <cfif listContains("#Form.fovorite_pet#","fish")>
    Fish
  </cfif>
  <cfif listContains("#Form.fovorite_pet#","cat")>
    Cat
  </cfif>
  <cfif listContains("#Form.fovorite_pet#","dog")>
    Dog
  </cfif>
  <cfif listContains("#Form.fovorite_pet#","rabbit")>
    Rabbit
  </cfif>
</cfif>

ColdFusion Tutorial test

Check boxes

No test is available or implemented for this ColdFusion Tutorial.

No User Comments.

No User Comments, be the first one to write your comments?

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
D0o
Your IP Address: 38.103.63.62
 

ScandicWeb is own by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.

[Home [Site Map [Privacy Statement [Site Feedback] [About ScandicWeb]


[ColdFusion [Flash [Search Engine Optimization [Graphics [Cascading Style Sheets (CSS) [JavaScript (JS) [Software]

Partner sites: ScandicSoft


Server time: 19. November 2008 Wednesday