I have a form for addresses and I am using Geocomplete to populate that form. I have my US states in a select who's options have values as state codes and text as state name. How can I have the return from the Geocomplete trigger make the the proper selection from 'administrative_area_level_1'?
What I have so far:
<select name="administrative_area_level_1" class="form-control">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
</select>
I have changed the following in geocomplete:
// Assign a given `value` to a single `$element`.
// If the element is an input, the value is set, otherwise it updates
// the text content.
setDetail: function($element, value){
if (value === undefined){
value = "";
} else if (typeof value.toUrlValue == "function"){
value = value.toUrlValue();
}
alert(value);
if ($element.is(":input")) {
$element.val(value);
} else if ($element.is('select')) {
alert($element.attr('name') + ' ' + value);
$element.children('text=' + value).attr("selected", "true");
} else {
$element.text(value);
}
},
I added the part for if .is('select). It's not getting entered though. I can see with the alert outside of the if block that the state is coming back by state name and state code, but am unsure how to catch it.