asked on November 1, 2021 Show version history

Hi,

I have seven dropdowns corresponding to the days of the week, see below:

in the dropdowns a user must enter the days they want off with 1 being most desirable day off to 7 being least desirable day off.  I would like to know how to make it so if a user puts a 1 in Monday the choice of 1 is removed from the rest of the dropdowns, so there isn't repetition of a number. 

I appropriated this, but I can't make it work (and I'm not sure if it's even correct for this):

$( document ).ready(function() {
  var locations = {
    'Monday':['1','2','3','4','5','6','7'],
    'Tuesday':['1','2','3','4','5','6','7'],
    'Wednesday':['1','2','3','4','5','6','7'] ,
    'Thursday':['1','2','3','4','5','6','7'] ,
    'Friday':['1','2','3','4','5','6','7'] ,
    'Saturday':['1','2','3','4','5','6','7'] ,
    'Sunday':['1','2','3','4','5','6','7'] ,    
}
  $('#q20').change(function () {
      var lcns = locations[$('#q20 select').val()] || [];
    $('#q21 select').find('#q20.val').remove();
    JQuery.each(lcns,function(i, val) {
       $('#q21 select').append(new Option(val, val, false, false));
       });

   });
});

the dropdowns are: Monday: #q20, Tuesday: #q21, Wednesday: #q22, Thursday: #q23, Friday: #q24, Saturday: #q25, Sunday: #q26.

If anyone can assist or show a better way to do this, it would be greatly appreciated!

Donnie

P.S. I don't have access to workflow, sorry.

0 0