Initializing Select Options in Spry

I was using Spry on a form that allowed the user to select a city. For the creation form I just used a standard Spry region, but for the edit form I needed to preselect the city. In order to do this you need to dynamically set a JavaScript variable based on the current value from the database and use that JavaScript variable in the Spry code. The following code shows how it is done:
<script type="text/javascript">
   var dsCities = new Spry.Data.XMLDataSet("xmlCities.cfm", "cities/city");
   var origCity="#MyQuery.CityID#";
</script>

<div id="cities" spry:region="dsCities">
<select spry:repeatchildren="dsCities" name="cityID" id="citySelect">
<option spry:if="{cityid} == origCity" selected="selected" value="{cityid}">{name}</option>
   <option spry:if="{cityid} != origCity" value="{cityid}">{name}</option>
</select>
</div>

BlogCFC was created by Raymond Camden. This blog is running version 5.004.