<i id='m26b2'><tr id='m26b2'><dt id='m26b2'><q id='m26b2'><span id='m26b2'><b id='m26b2'><form id='m26b2'><ins id='m26b2'></ins><ul id='m26b2'></ul><sub id='m26b2'></sub></form><legend id='m26b2'></legend><bdo id='m26b2'><pre id='m26b2'><center id='m26b2'></center></pre></bdo></b><th id='m26b2'></th></span></q></dt></tr></i><div id='m26b2'><tfoot id='m26b2'></tfoot><dl id='m26b2'><fieldset id='m26b2'></fieldset></dl></div>
      <legend id='m26b2'><style id='m26b2'><dir id='m26b2'><q id='m26b2'></q></dir></style></legend>

      1. <tfoot id='m26b2'></tfoot>

        <small id='m26b2'></small><noframes id='m26b2'>

          <bdo id='m26b2'></bdo><ul id='m26b2'></ul>
      2. Bootstrap 双列表框和单选,在 jquery 中使用添加/删

        时间:2023-10-13
        <legend id='nVcKt'><style id='nVcKt'><dir id='nVcKt'><q id='nVcKt'></q></dir></style></legend>
          <bdo id='nVcKt'></bdo><ul id='nVcKt'></ul>
            <i id='nVcKt'><tr id='nVcKt'><dt id='nVcKt'><q id='nVcKt'><span id='nVcKt'><b id='nVcKt'><form id='nVcKt'><ins id='nVcKt'></ins><ul id='nVcKt'></ul><sub id='nVcKt'></sub></form><legend id='nVcKt'></legend><bdo id='nVcKt'><pre id='nVcKt'><center id='nVcKt'></center></pre></bdo></b><th id='nVcKt'></th></span></q></dt></tr></i><div id='nVcKt'><tfoot id='nVcKt'></tfoot><dl id='nVcKt'><fieldset id='nVcKt'></fieldset></dl></div>
              <tbody id='nVcKt'></tbody>

          • <tfoot id='nVcKt'></tfoot>

            <small id='nVcKt'></small><noframes id='nVcKt'>

                  本文介绍了Bootstrap 双列表框和单选,在 jquery 中使用添加/删除/关闭选项在警报中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  请任何人帮我解决这个问题.

                  Can you please anyone help me how to solve this issue.

                  Bootstrap 有双列表框选项,只有单选/多选.

                  Bootstrap have dual listbox option with single/multiple select only.

                  我需要带有单选的双列表框.

                  I need dual listbox with single select.

                  说明:

                  例如:

                  我有双列表框,左列表框有 5 个选项.我需要单选.(即)如果我在左侧列表框中选择单个选项,它会显示弹出(警报)并获取相应的字段值,并且弹出窗口有添加取消 按钮添加/取消值.单击弹出窗口中的添加选项后,它将添加到右侧列表框中.

                  I have dual listbox,left listbox have 5 options. I need single select.(i.e) If i select the single option in the left listbox, it shown popup(alert) with fetching the respective field values and also the popup have Add or Cancel button to add/cancel the values.After clicking the add option in popup it will be added in right list box.

                  如果我选择右侧列表框中的选项,它再次显示弹出(警报)并获取相应的字段值,并且弹出窗口有 DeleteCancel 按钮删除/取消右侧列表框中的值.

                  And if i select the option in right listbox , again it shown popup(alert) with fetching the respective field values and also the popup have Delete or Cancel button to delete/cancel the values in the right listbox.

                  请任何人解决这个问题,

                  Please any one give solution to this problem,

                  谢谢,

                  推荐答案

                  //Html
                  <select id="sel1">
                      <option value="1">1</option>
                      <option value="2">2</option>
                      <option value="3">3</option>
                      <option value="4">4</option>
                  </select>
                  <select id="sel2"></select>
                  //This is the JS
                  //On change of the first select
                  $('#sel1').on('change', function (e) {
                      e.preventDefault();
                      var selVal = $(this).val();
                      var selHtml = $(this).find('option:selected').text();
                      moveItem('#sel1', '#sel2', selVal, selHtml);//call our function
                  });
                  //On change of the second select
                  $('#sel2').on('change', function (e) {
                      e.preventDefault();
                      var selVal = $(this).val();
                      var selHtml = $(this).find('option:selected').text();
                      moveItem('#sel2', '#sel1', selVal, selHtml);//call our function
                  });
                  //Move function take 4 parameters
                  function moveItem(moveFrom, moveTo, selVal, selHtml) {
                      if (confirm("Are you sure? : " + selVal)) {//Confirm dialogue box comes up and on selecting 'ok' this part will be executed
                          $(moveTo).append('<option value="' + selVal + '">' + selHtml + '</option>');//append a value to select
                          var mId = moveFrom + ' option[value="' + selVal + '"]';
                          $(mId).remove();//remove value from the other select
                      }
                      return false;
                  }
                  

                  这篇关于Bootstrap 双列表框和单选,在 jquery 中使用添加/删除/关闭选项在警报中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:HTML 列表框换行文本 下一篇:使用 CSS 或 jQuery 样式化 HTML 表单列表框

                  相关文章

                  最新文章

                  • <bdo id='xhgAO'></bdo><ul id='xhgAO'></ul>
                  1. <legend id='xhgAO'><style id='xhgAO'><dir id='xhgAO'><q id='xhgAO'></q></dir></style></legend>
                    <tfoot id='xhgAO'></tfoot>

                      <small id='xhgAO'></small><noframes id='xhgAO'>

                    1. <i id='xhgAO'><tr id='xhgAO'><dt id='xhgAO'><q id='xhgAO'><span id='xhgAO'><b id='xhgAO'><form id='xhgAO'><ins id='xhgAO'></ins><ul id='xhgAO'></ul><sub id='xhgAO'></sub></form><legend id='xhgAO'></legend><bdo id='xhgAO'><pre id='xhgAO'><center id='xhgAO'></center></pre></bdo></b><th id='xhgAO'></th></span></q></dt></tr></i><div id='xhgAO'><tfoot id='xhgAO'></tfoot><dl id='xhgAO'><fieldset id='xhgAO'></fieldset></dl></div>