Auto-fill text box field values based on pulldown selection
http://stackoverflow.com/questions/3657127/jquery-populate-text-input-from-table-based-on-select-value
Maybe someone has a CF version they could share?
<script type="text/javascript">
function selectAddress(list) {
// assume first item is empty
if (list.selectedIndex > 0) {
var locationID = list.options[list.selectedIndex].value;
var locationAddress = list.options[list.selectedIndex].locationAddress;
var locationCity = list.options[list.selectedIndex].locationCity;
var locationState = list.options[list.selectedIndex].locationState;
var locationZip = list.options[list.selectedIndex].locationZip;
document.getElementById('locationID').value = locationID;
document.getElementById('locationAddress').value = locationAddress;
document.getElementById('locationCity').value = locationCity;
document.getElementById('locationState').value = locationState;
document.getElementById('locationZip').value = locationZip;
}
}
</script>
<tr>
<td align="right" bgcolor="#FFFFFF" valign="top">Name of Destination</td>
<td align="left" bgcolor="#FFFFFF" valign="top">
<select name="locationID" onChange="selectAddress(this)" class="smallforms">
<option value="">SELECT DESTINATION ››››››››››</option>
<cfoutput query="allLocations">
<option value="#locationName#" locationAddress="#allLocations.locationAddress#" locationCity="#allLocations.locationCity#" locationState="#allLocations.locationState#" locationZip="#allLocations.locationZip#">#locationName#</option>
</cfoutput>
</select>
Other: <cfinput name="destinationNameOther" type="text" class="smallforms" size="75">
<br />
<input id="locationID" name="locationID" type="hidden"><br>
Address: <input class="smallforms" id="locationAddress" name="locationAddress" type="text" size="30">
City: <input class="smallforms" id="locationCity" name="locationCity" type="text" size="20">
State: <input class="smallforms" id="locationState" name="locationState" type="text" size="2">
Zip: <input class="smallforms" id="locationZip" name="locationZip" type="text" size="8"><br />
<br />
</td></tr>
