1
0
-1

i have a two multiselect box which the user can select a one value only from joget users (which generated automatically) , i have too another select box which user can select multiple valuse (which generated automatically too from joget users), now when user select the value in the first select box it must be hide from options in seconed select box ,
(no repeated value)  how can i do this ? 

note: the two select boxes in the same form

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hello there, 

      In the form builder,
      Add two select boxes: selectBox1 (single select) and selectBox2 (multi-select).

      Add a Custom HTML and, add this script:


      <script type="text/javascript">
          $(document).ready(function() {
              // Function to update options in the second select box
              function updateSelectBox2() {
                  var selectedValue = $('#selectBox1').val();
                  $('#selectBox2 option').show(); // Show all options initially
                  $('#selectBox2 option').each(function() {
                      if ($(this).val() === selectedValue) {
                          $(this).hide(); // Hide the selected value from selectBox1
                      }
                  });
              }

              // Event listener for changes in the first select box
              $('#selectBox1').change(function() {
                  updateSelectBox2();
              });

              // Initial call to update selectBox2 on page load
              updateSelectBox2();
          });
      </script>
      
      

      Make sure #selectBox1 and #selectBox2 match your select box IDs. This script hides the selected value in selectBox1 from selectBox2, avoiding repeated values.
      Adjust the code accordingly based your field ID 

      Hope this helps!

      1. nihal sabbarini

        thank you so much for your answer but it didnt work, so can you help me please ? 

        it does not run the code , i put jquery but still did not work and i am sure from IDs 

      CommentAdd your comment...