如何使用javascript显示更改另一个下拉项目的下拉值

时间:2014-05-30 19:06:08

标签: javascript jquery html

如何根据流向我的用户提供从下拉菜单中选择1个主题的选项 喜欢 - 流5Th主题 商务IP               其他

人性化知识               印地文

科学(PCM)CS               IP

科学(PCB)CS               印地文

但是我无法通过使用以下代码找到方法 -

 <script>
$(document).ready(function(){
var secondSelect = $("select[name='core']");
var thirdSelect = $("select[name='5thsub']");
var secondOptions = secondSelect.children('option');
var thirdOptions = thirdSelect.children('option');

$("select[name='stream']").change(function(){     
    var selectedIndex = this.selectedIndex;
    secondOptions.filter(function(i){ return i == selectedIndex})
                 .appendTo(secondSelect.empty());
    thirdOptions.filter(function(i){ return i == selectedIndex})
                 .appendTo(thirdSelect.empty());
}).change();
});
</script>
<tr>
  <td>Stream : &nbsp;&nbsp;&nbsp;&nbsp;
    <select name="stream">
    <option value="</option>">Commerce</option>
    <option value="Humanities">Humanities</option>
    <option value="Sci[PCM]">Sci[PCM]</option>
        <option value="Sci[PCB]">Sci[PCB]</option>
    </select>
  </td>
  <td>Core Subjects :   
    <select name="core">
        <option value="Eng,Acc,BST,Eco">Eng,Acc,BST,Eco</option>
        <option value="Eng,Hindi,Geo,His">Eng,Hindi,Geo,His</option>
    <option value="Eng,Phy,Che,Math">Eng,Phy,Che,Math</option>
        <option value="Eng,Phy,Che,Bio">Eng,Phy,Che,Bio</option>
    </select> 
  </td>
  <td>5th Subjects :       
     <select name="5thsub">
         <option value="IP & OTHER">IP & OTHER</option>
         <option value="IP & Other">IP & Hindi</option>
     <option value="CS & IP">CS & IP</option>
         <option value="Math & Hindi">Math & Hindi</option>
     </select>
  </td>
     <td>6th Subjects :
       <select name="6thsub" >
          <option value="Physical Education">Physical Education</option>        
       </select>
     </td>
 </tr>

0 个答案:

没有答案