You are viewing limited content. For full access, please sign in.

Question

Question

Javascript to append a name to a list stopped working

asked on March 3

I have a number of instances like this in a particular process where I am appending a name to a list. I set them up several years ago. But now I find that they are no longer working and I don't know why:

$(document).ready(function() {
  $('.approverDecision').on('click', function(){   
    var DeptHeads = [];     
    if ($('.deptCode input').val()=='0604000 City Attorney') {
      $.each($('.DeptHeadList option'), function(){
        DeptHeads.push($(this).val());
      });     
        if ($.inArray('JOHN DOE', DeptHeads) == -1){
              $('.DeptHeadList select').append('<option>JOHN DOE</option>');
      } 
    }
  });
});

But in a different process I'm doing the same thing and it IS working:

$(document).ready(function() {
   $('.sendToAltApvr input').on('click', function(){  
    var allApvrs = [];      
    if ($('.submitterEID input').val()=='12731'){
      $.each($('.AltApvList option'), function(){
        allApvrs.push($(this).val());
      });     
        if ($.inArray('JANE DOE', allApvrs) == -1){
              $('.AltApvList select').append('<option>JANE DOE</option>');
        }     
    }
   });
});

The one different between the two is in the "on click" function - the first example uses a radio button and the second example uses a checkbox. At first I thought it was just a matter of adding "input" after ".approverDecision" but that didn't work either. I appreciate any advice. This is version 11. Thank you.

0 0

Replies

replied on March 3

Hi Susan,

I tried your script and it works for me:

Can you double check if you have set the CSS class as defined?

And for the field with class 'deptCode', what kind of field is it?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.