简体   繁体   中英

Default selection of country by a 3rd party JS

I have one query:

Currently user need to select one country then the states of that country are coming in state field automatically. But I want united state selected by default with its states in the state field. How can I do this: Below is my code.....what parameters to pass

ll(document).ready(function() {
ll("#country").change(function(){
    ChangeCountryAndStateLabel({
       'obj'       : this,
       'targetObj' : '#state_cus1',
       'sel'       : '',
       'id'        : 'fields_state'
    },{
       'obj'       : this,
       'targetObj' : '#fields_state_region',
       'template'  : '<LABEL>'
    });


});

You can do that like;

HTML:

<select id="select">
    <option value="utah">Utah</option>
    <option value="united-states">united states</option>
</select>

JS:

$(document).ready(function(){
    $("#select").val("united-states");
})

You can use this after your code. Only this part:

$("#select").val("united-states");

See working fiddle here: http://jsfiddle.net/3Dkfe/

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM