Lines 1-42
Link Here
|
1 |
$(document).ready(function() { |
1 |
$(document).ready(function () { |
2 |
$("#desk_id").children().each(function() { |
2 |
$("#branch") |
3 |
var selectedBranch = $("#branch"). children("option:selected"). val(); |
3 |
.on("change", function () { |
4 |
if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element |
4 |
$("#desk_id") |
5 |
$(this).prop("selected", true); |
5 |
.children() |
6 |
$(this).prop("disabled", false); |
6 |
.each(function () { |
7 |
$(this).show(); |
7 |
var selectedBranch = $("#branch") |
8 |
} |
8 |
.children("option:selected") |
9 |
else if ($(this).hasClass(selectedBranch)) { |
9 |
.val(); |
10 |
$('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option |
10 |
if ($(this).attr("id") === "nodesk") { |
11 |
$('#nodesk').hide(); |
11 |
// set no desk by default, should be first element |
12 |
$(this).prop("disabled", false); |
12 |
$(this).prop("selected", true); |
13 |
$(this).show(); |
13 |
$(this).prop("disabled", false); |
14 |
$(this).prop("selected", true) |
14 |
$(this).show(); |
15 |
} else { |
15 |
} else if ($(this).hasClass(selectedBranch)) { |
16 |
$(this).prop("disabled", true); |
16 |
$("#nodesk").prop("disabled", true); // we have desk, no need for nodesk option |
17 |
$(this).hide(); |
17 |
$("#nodesk").hide(); |
18 |
} |
18 |
$(this).prop("disabled", false); |
19 |
}); |
19 |
$(this).show(); |
20 |
|
20 |
if ( |
21 |
$("#branch").on("change", function() { |
21 |
selectedBranch == $(".logged-in-branch-code").html() |
22 |
|
22 |
) { |
23 |
$("#desk_id").children().each(function() { |
23 |
$("#desk_id").val($(".logged-in-desk-id").html()); |
24 |
var selectedBranch = $("#branch"). children("option:selected"). val(); |
24 |
} else { |
25 |
if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element |
25 |
$("#nodesk").hide(); |
26 |
$(this).prop("selected", true); |
26 |
$("#desk_id").val( |
27 |
$(this).prop("disabled", false); |
27 |
$("#desk_id option:not([disabled]):first").val() |
28 |
$(this).show(); |
28 |
); |
29 |
} |
29 |
} |
30 |
else if ($(this).hasClass(selectedBranch)) { |
30 |
} else { |
31 |
$('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option |
31 |
$(this).prop("disabled", true); |
32 |
$('#nodesk').hide(); |
32 |
$(this).hide(); |
33 |
$(this).prop("disabled", false); |
33 |
} |
34 |
$(this).show(); |
34 |
}); |
35 |
$(this).prop("selected", true) |
35 |
}) |
36 |
} else { |
36 |
.change(); |
37 |
$(this).prop("disabled", true); |
37 |
}); |
38 |
$(this).hide(); |
|
|
39 |
} |
40 |
}); |
41 |
}); |
42 |
}) ; |
43 |
- |
|
|