Coldfusion and Pausing Javascript

I had an interesting problem this week. I had a page with a CFQuery, a CFLoop to output the query, and a javascript function. The problem was that the javascript function was occurring before the loop would draw the output. This kept those objects (Form elements) from being available to the dom. So I needed a way to pause the javascript.

The Solution:
</cfloop>
<script>
function myFunction(){
//do something
}
// execute myFunction after 2 seconds.
setTimeOut(myFunction, 2000);
</script>

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion, Javascript, Problems & Fixes, Snippets. Bookmark the permalink.