address_autocomplete($country, $string = '')
ecommerce-5--4/address/address.module, line 64
Create a list of states from a given country
$country String, the country code
$string String (optional), the state name typed by user
Javascript array, list of states
<?php
function address_autocomplete($country, $string = '') {
$string = strtolower($string);
$string = '/^'. $string .'/';
$matches = array();
include_once drupal_get_path('module', 'store') .'/store.localization.inc';
$states = _store_location_states($country);
if (!empty($states)) {
while (list($code, $name) = each($states)) {
if ($counter < 5) {
if (preg_match($string, strtolower($name))) {
$matches[$code] = strtolower($name);
++$counter;
}
}
}
}
echo drupal_to_js($matches);
exit();
}
?>