I need one help. I need to set value to select box dynamically and trigger the change event. I am explaining my code below.
<select class="chosen-select text-left" style="width:100%;" onchange="setCountry();" id="conid">
<option value="" selected>Select Country</option>
<?php
foreach ($country as $v) {
?>
<option value="<?php echo $v['country_id']; ?>"><?php echo $v['country_name']; ?></option>
<?php
}
?>
</select>
Here I am fetching the value like below.
var conval=document.getElementById('conid');
selectVal=conval.options[conval.selectedIndex].text;
Suppose I have one country name India and I need to set dynamically to that select box and at the same time the change event(i.e-setCountry) will trigger.Please help me.