Qualtrics: dropdown copy the value into another multiple dropdown js

Viewed 19

I'm trying to work with multiple dropdown, the 1st dropdown is supposed to copy all the value in 3 other dropdown however I only manage to find a solution in a single one.

Here's the code I tried:

var select1 = document.getElementById("dropdown1"); //1st dropdown id

var select2 = document.getElementById("dropdown2"); //2nd dropdown id

select1.onchange = function() {

  // empty select2

  while (select2.firstChild) {

    select2.removeChild(select2.firstChild);

  }

  if (select1.selectedIndex == 0) {

    return;

  }

  for (var i = select1.selectedIndex; i < select1.options.length; i++) {

    var o = document.createElement("option");

    o.value = select1.options[i].value;

    o.text = select1.options[i].text;

    select2.appendChild(o);

  }

}

Output:

enter image description here

0 Answers
Related