ColdFusion is server side. Once the page loads, CF is done. JS is client side. You can't reference CF code inside of JS after the page loads (not without getting AJAX-y).
you can create JS variables with CF: <script type="text/javascript"> var myFoo = "<cfoutput>#myQuery.foo#</cfoutput>"'; </script> if you view the source of that page after it loads, you'll see the JS is valid. it's identical to using CF to create HTML. However, once the page loads, you can no longer rely on CF to create any client side code. To do what you want, you'd use CF to create a JS array and your onclick would use that array. On 11/14/06, Jason T. Slack <[EMAIL PROTECTED]> wrote: > I am on Day 5 with CF and Coming along nicely. > > I have a question on mixing CF and Javascript. > > Say I have the following with an onBlur event: > > <input type="textfield" name="upc" id="upc" size="12" maxlength="12" > onblur="lookUpUPC(this.value);" /> > > Here is the JS for LookUpUPC() > > function lookUpUPC(upc) > { > <cfquery name="ckUPC" datasource="#application.dsn#"> > SELECT Description, UnitPrice FROM Inventoryitems > WHERE upc = <Cfqueryparam cfsqltype="cf_sql_varchar" > value=upc>; > </cfquery> > > <cfif ckUPC.recordCount EQ 1> > alert("UPC FOUND"); > <cfelse> > alert("UPC NOT FOUND"); > </cfif> > } > > > When LookUpUPC fires I get just the alert boxes that I coded in for > information purposes. I tried hard coding the query with a valid upc > in the database and still I get UPC not found. > > So I must be doing something wrong but I am not sure what. > > Can anybody shed some light? > > -Jason > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:260375 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4