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

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

      1. <legend id='B82YV'><style id='B82YV'><dir id='B82YV'><q id='B82YV'></q></dir></style></legend>

        如何根据另一个下拉列表中的选择选择下拉列表

        时间:2023-10-02

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

            <tfoot id='Qe0Oi'></tfoot>

              <bdo id='Qe0Oi'></bdo><ul id='Qe0Oi'></ul>
                <tbody id='Qe0Oi'></tbody>
              <legend id='Qe0Oi'><style id='Qe0Oi'><dir id='Qe0Oi'><q id='Qe0Oi'></q></dir></style></legend>

                • <i id='Qe0Oi'><tr id='Qe0Oi'><dt id='Qe0Oi'><q id='Qe0Oi'><span id='Qe0Oi'><b id='Qe0Oi'><form id='Qe0Oi'><ins id='Qe0Oi'></ins><ul id='Qe0Oi'></ul><sub id='Qe0Oi'></sub></form><legend id='Qe0Oi'></legend><bdo id='Qe0Oi'><pre id='Qe0Oi'><center id='Qe0Oi'></center></pre></bdo></b><th id='Qe0Oi'></th></span></q></dt></tr></i><div id='Qe0Oi'><tfoot id='Qe0Oi'></tfoot><dl id='Qe0Oi'><fieldset id='Qe0Oi'></fieldset></dl></div>
                • 本文介绍了如何根据另一个下拉列表中的选择选择下拉列表中的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有两个已经从数据库填充的下拉列表.如果您在 DropDownlist1 中选择一个值 - Dropdownlist2 获得与 Dropdownlist1 中选择的值相同的值.

                  I have two DropDown lists which are already populated from the database. If you select a value in DropDownlist1 - Dropdownlist2 gets the same value that was selected in Dropdownlist1.

                  但是代码是基于 switch case 的,而且选项也是硬编码的!将来 - 可能会出现许多选项,但它不会起作用!

                  But the code is based on switch case and also the options are hard coded ! In future - Many options might spring up and it will not work !

                  所以我想要的是如果您在下拉列表 1 中选择一个选项 - 应根据值"而不是索引"在下拉列表 2 中选择该选项 喜欢这里

                  So what I want is If you select an option in Dropdown list 1 - The option should be selected in DropDown list 2 based on the "value" and not "index" Like here

                  任何指示或帮助将不胜感激!提前致谢

                  Any pointers or help would be appreciated ! Thanks in advance

                   function showSelected(f) {
                  
                  var selNum  = f.type1.selectedIndex;
                  //var selText = f.type1.options[selNum].text
                  
                  
                  switch (selNum)
                  {
                  case 1:
                  document.getElementById('type2').selectedIndex= 2;
                  break;
                  
                  case 2:
                  document.getElementById('type2').selectedIndex = 8;
                  break;
                  
                  case 3:
                  document.getElementById('type2').selectedIndex = 3;
                  break;
                  
                  case 4:
                  document.getElementById('type2').selectedIndex = 1;
                  break;
                  
                  case 5:
                  document.getElementById('type2').selectedIndex = 4;
                  break;
                  
                  case 6:
                  document.getElementById('type2').selectedIndex = 2;
                  break;
                  
                  case 7:
                  document.getElementById('type2').selectedIndex = 2;
                  break;
                  
                  case 8:
                  document.getElementById('type2').selectedIndex = 7;
                  break;
                  
                  }
                  
                  
                  }
                  
                   <select name="Type1" id="Type1" onchange="showSelected(this.form)" >
                  <option>Select Option</option>
                      <option  value="<?php echo $record->getID();?>" > <?php echo $record->getIDName();?> </option>
                   </select>       
                  
                   <select name="Type2" id="Type2" disabled>
                  <option>Select Option</option>
                      <option  value="<?php echo $record->getID();?>" ><?php echo $record->getIDValue();?> </option>
                   </select>     
                  

                  推荐答案

                  function selectoption()
                      {
                          var list = document.getElementById('list');
                          var listtwo = document.getElementById('listtwo');
                          var searchtext = list.options[list.selectedIndex].text; 
                          for(var i = 0; i < listtwo.options.length; ++i)
                              if (listtwo.options[i].text === searchtext) listtwo.options[i].selected = true;
                      }
                  

                  http://jsbin.com/oyaloc/2

                  这篇关于如何根据另一个下拉列表中的选择选择下拉列表中的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用使用 AJAX/PHP 填充的 DropDownList 中选定值 下一篇:更改第一个 DropDownList 后如何从数据库加载第二个

                  相关文章

                  最新文章

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

                      <tfoot id='QF6Ip'></tfoot>

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

                    1. <legend id='QF6Ip'><style id='QF6Ip'><dir id='QF6Ip'><q id='QF6Ip'></q></dir></style></legend>