I think it is this:
<cfif structKeyExists(url,"getClientId")>

<cfquery name="res" datasource="yourdsn">
select *
from ajax_client
where clientID='#url.getClientId#'
</cfquery>
 <cfif res.recordCount gt 0>
<cfoutput>
formObj.firstname.value = '#res.firstname#';
formObj.lastname.value = '#res.lastname#';
formObj.address.value = '#res.address#';
formObj.zipCode.value = '#res.zipCode#';
formObj.city.value = '#res.city#';
formObj.country.value = '#res.country#';
</cfoutput>
<cfelse>
<cfoutput>
formObj.firstname.value = '';
formObj.lastname.value = '';
formObj.address.value = '';
formObj.zipCode.value = '';
formObj.city.value = '';
formObj.country.value = '';
</cfoutput>
</cfif>

</cfif>

But a simpler version that is almost the same (adding in cfqueryparam and
jsstringformat):

<cfparam name="url.getClientId" default="0">

<cfquery name="res" datasource="yourdsn">
select *
from ajax_client
where clientID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#url.getClientId#">
</cfquery>

<cfoutput>
formObj.firstname.value = '#jsStringFormat(res.firstname)#';
formObj.lastname.value = '#jsStringFormat(res.lastname)#';
formObj.address.value = '#jsStringFormat(res.address)#';
formObj.zipCode.value = '#jsStringFormat(res.zipCode)#';
formObj.city.value = '#res. jsStringFormat(city)#';
formObj.country.value = '#jsStringFormat(res.country)#';
</cfoutput>


2009/8/16 <[email protected]>

>  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.html
>
> 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:
>
> www.SAMARIS.NET <http://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to