Bug 28445: UI change for repeatable and regex
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / register_selection.js
1 $(document).ready(function() {
2     $("#branch").on("change", function() {
3         var selectedBranch = $("#branch").children(
4             "option:selected").val();
5
6         $("#register_id").children().each(function() {
7             // default to no-register
8             if ($(this).is("#noregister")) {
9                 $(this).prop("selected", true)
10             }
11             // display branch registers
12             else if ($(this).hasClass(selectedBranch)) {
13                 $(this).prop("disabled", false);
14                 $(this).show();
15                 // default to branch default if there is one
16                 if ($(this).hasClass("default")) {
17                     $(this).prop("selected", true)
18                 }
19             }
20             // hide non-branch registers
21             else {
22                 $(this).hide();
23                 $(this).prop("disabled", true);
24             }
25         });
26     });
27 });