Advertisement
bennyp

Untitled

Nov 27th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                     function backgroundchange(iditem) {
  2.                         const selectId = `selectstatus${iditem}`
  3.                         const selectedDisplay = document.querySelector(`#${selectId} ~ .dropdown-menu .selected a`)
  4.                         const select = document.getElementById(selectId);
  5.                         const styleElement = document.getElementById(`stylestatusselection${iditem}`);
  6.                         const [statuscode, ...statuscolorchars] = select.options[select.selectedIndex].value;
  7.                         const statuscolorcode = statuscolorchars.join('');
  8.  
  9.                         styleElement.innerHTML = `
  10.                         #${selectId} ~ .dropdown-menu .selected a,
  11.                         .statusselectionbackground${iditem} {
  12.                             background-color: #${statuscolorcode}
  13.                         }`;
  14.  
  15.                         // Remove style attribute from all dropdown options
  16.                         // I'm not sure where this style attribute was initially set.
  17.                         // If you find where that happens, you can just remove that code,
  18.                         // which would make the following two lines superfluous.
  19.                         const links = document.querySelector(`#${selectId} ~ .dropdown-menu`).querySelectorAll('a')
  20.                         links.forEach(option => option.removeAttribute('style'))
  21.  
  22.                         $.ajax({
  23.                             url: `backofficerequestsstatusupdate.php?requestorid=${iditem}&statuscode=${statuscode}`,
  24.                             method: 'get',
  25.                         });
  26.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement