Used within a cfloop tag. Returns processing to the top of a loop.


Flow-control tags



See also

cfabort, cfbreak, cfexecute, cfif, cflocation, cfloop, cfthrow, cftry; cfloop and cfbreak in the Developing ColdFusion Applications


ColdFusion 9: Added the tag.


<!--- This shows the use of to return processing to the top of a loop when a condition is met.---> 
<!--- Select courses; use cfloop to find a condition; then break the loop. ---> 
<!--- Check that number is numeric. ---> 
<cfif IsDefined("form.course_number")> 
    <cfif Not IsNumeric(form.course_number)> 
<cfquery name="GetCourses" datasource="cfdocexamples"> 
    SELECT *  
    FROM Courses  
    ORDER by course_number  
<p> This example uses CFLOOP to cycle through a query to find a value. 
(In our example, a list of values corresponding to courses in the cfdocexamples 
datasource). When the conditions of the query are met, CFBREAK stops the loop. </p> 
<p> Please enter a Course Number, and hit the "submit" button: </p> 
<form action="cfbreak.cfm" method="POST">  
    <select name="courseNum">  
        <cfoutput query="GetCourses">  
            <option value="#course_number#">#course_number# 
    <input type="Submit" name="" value="Search on my Number">  
<!--- If the courseNum variable is not defined, don't loop through the query.---> 
<cfif IsDefined ("form.courseNum") IS "True"> 
<!--- Loop through query until value found, then use CFBREAK to exit query.---> 
    <cfloop query="GetCourses">  
        <cfif GetCourses.course_number IS form.courseNum>  
                <h4>Your Desired Course was found:</h4>  
                <pre>#course_number# #descript#</pre> 
            <br> Searching...