Yeah, you're right on track, this can be done with Javascript.  The easiest
way is to take advantage of CFWDDX and have your locations stored in a
Javascript structure.

<cfscript>
        Locations = structnew();
        Locations["3"] = structnew();
        Locations["3"].Label = "Work - Ocean Beach";
        Locations["3"].Address = "4835 Voltaire Street";
        Locations["3"].City = "San Diego";
        Locations["3"].State = "CA";
        Locations["3"].ZipCode = "92107";
        Locations["3"].Country = "US";
        Locations["6"] = structnew();
        Locations["6"].Label = "Home - Pacific Beach";
        Locations["6"].Address = "15 Main Street";
        Locations["6"].City = "San Diego";
        Locations["6"].State = "CA";
        Locations["6"].ZipCode = "92109";
        Locations["6"].Country = "US";
</cfscript>

<script language="JavaScript">
<cfwddx action="CFML2JS" input="#Locations#" toplevelvariable="oLocations">
</script>

Create a custom handler for your select box's onchange event.  That function
can use the selection's value to determine which element in the structure to
use when populating the other form fields (address, city, state, etc).

var nIndex =
LocationsSelectBox.options[LocationsSelectBox.selectedIndex].value;
document.yourform.address.value = oLocations[nIndex].address;
document.yourform.city.value = oLocations[nIndex].city;

etc...

HTH

---
Paul Mone
Ninthlink Consulting Group
[EMAIL PROTECTED]
http://www.ninthlink.com
619.222.7082


-----Original Message-----
From: S R [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 29, 2001 6:01 PM
To: CF-Talk
Subject: auto-form fill in


Does anyone know of a custom cf tag or javascript where once a user chooses
an item from a pull down menu it will fill in the address fields of the form
automatically? I'm thinking the page would first do a query of a table that
contains all the companies and their addresses the users could choose from
and store it in an array, then whichever 'company' the user chooses it will
refer to the array and match the comapny ID numbers and auto-fill the info?

SR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to