1 $(document).ready(function() {
3 $("#branch").on("change", function() {
5 $("#desk_id").children().each(function() {
6 var selectedBranch = $("#branch"). children("option:selected"). val();
7 if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
8 $(this).prop("selected", true);
9 $(this).prop("disabled", false);
12 else if ($(this).hasClass(selectedBranch)) {
13 $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
15 $(this).prop("disabled", false);
17 if ( selectedBranch == $(".logged-in-branch-code").html() ) {
18 $("#desk_id").val($(".logged-in-desk-id").html());
21 $("#desk_id").val($("#desk_id option:not([disabled]):first").val());
24 $(this).prop("disabled", true);