Hi Claude, Here is an approximation of the CF code to replace the PHP code snippet you cited. ============================================ <cfparam name="getClientId" type="any">
<cfquery name="getAjaxClient" datasource ="#application.yourDSN#"> select * from ajax_client where clientID='#getClientId#' </cfquery> <cfif getAjaxClient.recordcount gt 0> formObj.firstname.value = getAjaxClient.firstname> formObj.lastname.value = getAjaxClient.lastname> formObj.address.value = getAjaxClient.address> formObj.zipCode.value = getAjaxClient.zipCode> formObj.city.value = getAjaxClient.city> formObj.country.value = getAjaxClient.country> <cfelse> formObj.firstname.value =''> formObj.lastname.value = ''> formObj.address.value = ''> formObj.zipCode.value = ''> formObj.city.value = ''> formObj.country.value =''> </cfif> =============================================== By the way, I suggest that you google search for CFAJAX, as it might help you with the Ajax thing (useful if you are using something like CF 6). Cheers, Bryn Parrott ================================================== From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Sunday, 16 August 2009 10:59 AM To: [email protected] Subject: [cfaussie] Ajax Form Data Lookup Hi, I have found a great AJAX form lookup script to auto populate form field elements based on data entered from the first form element. For those of you interested the above is located at http://www.dhtmlgoodies.com/index.html?page=ajax http://www.dhtmlgoodies.com/scripts/ajax-client-lookup/ajax-client-lookup.ht ml http://www.dhtmlgoodies.com/index.html?whichScript=ajax_client_lookup The only problem I the above requires the following few lines of php code to run, yet it can be re written in cold fusion. As I am not familiar with reading PHP code I was wondering if someone could lend a hand translating it into equivalent cf code. <?php /* Replace the data in these two lines with data for your db connection */ $connection = mysql_connect("host","username","password"); mysql_select_db("databaseName",$connection); if(isset($_GET['getClientId'])){ $res = mysql_query("select * from ajax_client where clientID='".$_GET['getClientId']."'") or die(mysql_error()); if($inf = mysql_fetch_array($res)){ echo "formObj.firstname.value = '".$inf["firstname"]."';\n"; echo "formObj.lastname.value = '".$inf["lastname"]."';\n"; echo "formObj.address.value = '".$inf["address"]."';\n"; echo "formObj.zipCode.value = '".$inf["zipCode"]."';\n"; echo "formObj.city.value = '".$inf["city"]."';\n"; echo "formObj.country.value = '".$inf["country"]."';\n"; }else{ echo "formObj.firstname.value = '';\n"; echo "formObj.lastname.value = '';\n"; echo "formObj.address.value = '';\n"; echo "formObj.zipCode.value = '';\n"; echo "formObj.city.value = '';\n"; echo "formObj.country.value = '';\n"; } } ?> Regards Claude Raiola B.Econ (Acc), B.Hot.Mngt. Websites: <http://www.samaris.net> www.SAMARIS.NET Mobile: 0414 228 948 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~----------~----~----~----~------~----~------~--~---
