Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var department = '<?php echo $dept; ?>';
- //var department = 'Deployment'; <--- thats what $dept is
- ////// PROJECT CHANGE
- $('#projectSelect').on('change', function() {
- var selectedProject = $('#projectSelect').val();
- $.getJSON('json.php?task='+selectedProject, function(data) {
- var select = $('#taskSelect');
- select.empty();
- $.each(data, function(key, val){
- select.append("<option value='"+this.id+"'>"+this.label+"</option>");
- });
- /******** THIS IS WHERE I NEED HELP ... **********/
- if (department == this.label) {
- $("#taskSelect").val([this.id]).select2();
- }
- /*************************************************/
- var taskSelected = $('#taskSelect');
- $("#taskSelect").select2().select2('value', taskSelected);
- });
- })
- $.each(data, function(key, val){
- var opt = $("<option value='"+this.id+"'>"+this.label+"</option>");
- if(department == this.label)
- opt.attr("selected","selected");
- select.append(opt);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement