I have a form field called Zip and want to lookup/populate the city/state fields based on the zipcode entered. I'm thinking of using an onblur event to call the following JS function. Question how can I access the variable passed to the JS function inside a CF query? Is there a better way of accomplishing this lookup?
<CFPARAM name="vZip" default=""> <CFINPUT TYPE="text" NAME="Zip" SIZE="5" MAXLENGTH="5" onBlur="zipLookup(this.form.Zip)"> <script language="JavaScript"> function zipLookup(zipcode) { if ((zipcode == "") || (zipcode.length < 5) || (zipcode.length > 5)) { alert('Please enter a five digit zipcode!'); document.Log.zip.value = ''; document.Log.zip.focus(); return false; } else </script> ????<CFSET vZip = <script language="JavaScript">zipcode</script> >???? <CFQUERY name="qZipLook" datasource="dsn"> SELECT City, State FROM tbl_zipcodes WHERE zipcode = Trim(Variables.vZip) </CFQUERY> <CFIF IsDefined("qZipLook.RecordCount") AND qZipLook.RecordCount EQ 1 AND Variables.vZip is not ""> <script language="JavaScript"> document.Log.City.value = '<cfoutput>#qZipLook.City#</cfoutput>'; document.Log.State.value = '<cfoutput>#qZipLook.State#</cfoutput>'; </script> </CFIF> <script language="JavaScript"> return true; } </script> thanks, Dave HTC Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4