Code
$('#shipping-address select[name=\'country_id\']').trigger('change');
$('#shipping-address select[name=zone_id]').html('<option value="'+address_arr[8]+'" selected="selected">'+address_arr[10]+'</option>');
result
Question: I using trigger to refresh the dropdown list, but when my result is Terengganu it will auto jump to first one which is Johor , after tirgger I ald try to selected the results.
Please advise :(
I tried this code and it works fine:
<script type="text/javascript">
jQuery(function ($) {
var var1 = 'Barojerd';
$(document.body).on('change', '#shipping_country', function () {
if ($('#shipping_country').val() == 'IR')
$("#zone_id").append('<option selected="selected">' + var1 + '</option>');
else
$("#zone_id").append('<option>' + var1 + '</option>');
$(bCity).change();
});//end change country------------------------------------------
$(document.body).on('change', '#zone_id', function () {
setTimeout(function(){$('body').trigger('update_checkout'); }, 250 );
});//end change zone_id---------------------------------------------
});
</script>
and To receive Dropِown text:
var e = document.getElementById("shipping_country");
shipping_country_Text= e.options[e.selectedIndex].text;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.