home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfbreak.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.4 KB  |  57 lines

  1. <!--- This example shows the use of CFBREAK to exit
  2. a loop when a condition is met --->
  3.  
  4. <!--- select a list of courses and use CFLOOP to find a condition
  5. and then break the loop --->
  6. <CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
  7. SELECT * 
  8. FROM Courses
  9. ORDER by Number
  10. </CFQUERY>
  11.  
  12. <HTML>
  13. <HEAD>
  14. <TITLE>
  15. CFBREAK Example
  16. </TITLE>
  17. </HEAD>
  18.  
  19. <BODY bgcolor=silver>
  20. <H3>CFBREAK Example</H3>
  21.  
  22. <P>This example uses CFLOOP to cycle through a query to find a desired value.
  23. (In our example, a list of values corresponding to courses in the Snippets datasource).
  24. When the conditions of the query are met, CFBREAK stops the loop.
  25.  
  26. <P>Please enter a Course Number, and hit the "submit" button:
  27.  
  28. <FORM ACTION="cfbreak.cfm" METHOD="POST">
  29. <SELECT NAME="courseNum">
  30. <CFOUTPUT query="GetCourses">
  31. <OPTION VALUE="#Number#">#Number#
  32. </CFOUTPUT>
  33. </SELECT>
  34. <INPUT TYPE="Submit" NAME="" VALUE="Search on my Number">
  35. </FORM>
  36.  
  37. <!--- if the courseNum variable is not defined, don't loop
  38. through the query --->
  39. <CFIF IsDefined ("form.courseNum") is "True">
  40.  
  41. <!--- loop through the query until desired value is found,
  42. then use CFBREAK to exit the query --->
  43. <CFLOOP QUERY="GetCourses">
  44.     <CFIF GetCourses.Number is "#form.courseNum#">
  45.     <CFOUTPUT>
  46.     <H4>Your Desired Course was found:</H4>
  47.     <PRE>#Number#    #Descript#</PRE></CFOUTPUT>
  48.     <CFBREAK>
  49.     <CFELSE>
  50.         <BR>Searching... 
  51.     </CFIF>
  52. </CFLOOP>
  53. </CFIF>
  54.  
  55. </BODY>
  56. </HTML>       
  57.