Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. var department = '<?php echo $dept; ?>';
  2. //var department = 'Deployment'; <--- thats what $dept is
  3.  
  4. ////// PROJECT CHANGE
  5. $('#projectSelect').on('change', function() {
  6.  
  7. var selectedProject = $('#projectSelect').val();
  8. $.getJSON('json.php?task='+selectedProject, function(data) {
  9. var select = $('#taskSelect');
  10. select.empty();
  11.  
  12. $.each(data, function(key, val){
  13. select.append("<option value='"+this.id+"'>"+this.label+"</option>");
  14. });
  15.  
  16. /******** THIS IS WHERE I NEED HELP ... **********/
  17. if (department == this.label) {
  18. $("#taskSelect").val([this.id]).select2();
  19. }
  20. /*************************************************/
  21.  
  22. var taskSelected = $('#taskSelect');
  23. $("#taskSelect").select2().select2('value', taskSelected);
  24.  
  25. });
  26.  
  27. })
  28.  
  29. $.each(data, function(key, val){
  30. var opt = $("<option value='"+this.id+"'>"+this.label+"</option>");
  31.  
  32. if(department == this.label)
  33. opt.attr("selected","selected");
  34.  
  35. select.append(opt);
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement