CA Service Management

 View Only
  • 1.  Accessing the Approve / Rejected dropdown

    Posted Jan 04, 2017 12:18 PM

    I am trying to access the Approved / Rejected dropdown found near the upper right corner, and show / hide content based on an onChange. I grabbed a view source and found that the ID for that select dropdown is "ddlist_10205_21", or at least I think that is the ID. However, my code doesn't seem to work.

     

          document.getElementById("ddlist_10205_21").onChange = function() {
              if (document.getElementById("ddlist_10205_21").value == "800") {
                  console.log('Approved');
              } else {
                  console.log('Nope');
              }
          }

     

    Any advice?



  • 2.  Re: Accessing the Approve / Rejected dropdown

    Posted Jan 04, 2017 02:46 PM

    I don't think this is going to be viable as it appears the HTML id of that select field is unique per request. I raised 3 requests and the 'Pending Approval' dropdown had the following id's respectively:

     

    ddlist_10176_135
    ddlist_10176_136
    ddlist_10176_137

     

    What are you trying to accomplish in the if/else? 



  • 3.  Re: Accessing the Approve / Rejected dropdown

    Posted Jan 04, 2017 02:56 PM

    Arg... I thought that might be the case.

    My thought was to show / hide content based off of that dropdown.



  • 4.  Re: Accessing the Approve / Rejected dropdown
    Best Answer

    Posted Jan 06, 2017 12:38 PM

    I was able to accomplish this via the following:

     

    getApproval:function(){
      var div = Array.prototype.slice.call(document.querySelectorAll('select[id^="ddlist_"]'));
      div.forEach(function(sel){
        console.log('in forEach...id: '+sel.id);
        document.getElementById(sel.id).addEventListener('change', function() {
          if (document.getElementById(sel.id).value == "800") {
            console.log('Approved');
            ca_fdShowField(ca_fd.formId,'txta_3');
          } else {
              console.log('Nope');
            }
          });
        });
      }