Trigger change on select element
http://www.sitepoint.com/forums/showthread.php?1205047-click-optionbox
by Julien Etienne
HTML
<select id="owned_user_list" class="owned_user_list" url="/account/switch">
<option value="@followbacklist3">Option 1</option>
<option selected="selected" value="@teamfollowbak59">Option 2</option>
<option value="Add_new">Option 3</option>
</select>
JavaScript
const hasEvent = typeof(Event) === 'function';
const initEvent = (type) => {
const event = document.createEvent('Event');
event.initEvent(type, true, true);
}
const event = hasEvent ? new Event('submit'): initEvent('submit');
var sel = document.getElementById("owned_user_list");
// Attach event handler
sel.onchange = function(){
alert("I changed");
}
// Works in IE9+
var event = document.createEvent('HTMLEvents');
event.initEvent('change', true, false);
sel.dispatchEvent(event);