0
I need to make this code work the way that if it contains the word in the url I switch to the default option as follows:
$('#servico').val(Sispostag.getParameterValue('servico'));
var url = location.href;
if(url.indexOf('undefined')==-1) {
$('#servico').val(Sispostag.getParameterValue('servico'));
var elementS = document.getElementById('servico');
elementS.dispatchEvent(new Event('change'));
} else {
$('#servico').val('123');
var elementS = '123';
elementS.dispatchEvent(new Event('change'));
}
But always returns this error: Uncaught Typeerror: Elements.dispatchEvent is not a Function.
Can anyone help me resolve this error?