Check value of dropdown with JavaScript | XM Community
Skip to main content

I am trying to check on the value of a drilldown selection against a dictionary of values, so that I can stop the user if specific values where selected.
I managed to use the

this.questionclick
event listener successfully, however it does not work on mobile because drilldowns are displayed differently on mobile, and a click is not registered when the user clicks on an actual selection on the drilldown as opposed to it registering a click on non-mobile.
Now, I am trying to set up an
onchange
event instead of
onclick
but I cannot manage to figure out how to do it. Could anyone help?

This is my code that works:
this.questionclick = function(event, element) {

if (event.which != 0) {
return true;
}

if (element.name != 'QR~QID123~2') {
return true;
}

var selection = jQuery("#"+this.questionId+" option:selected").eq(1).html();

if (!selection) {
return true;
}

for (let i = 1; i <= 10; i++) {
if (selection == carreras[i]) {
var found = true;
var label = carreras[i];
};
};
if (found) {
this.hideNextButton();
alert('Recuerda, esta carrera no puede estar en tu postulación actual.');
} else {
this.showNextButton();
};
};

Try to use

oninput


Leave a Reply