一个下拉列表,选择A项目时,对应的A显示,BC层隐藏, 选择B项时,对应的B层显示,AC层隐藏。求:
1:此功能的JS代码。
2:如何获得此select选中的值(asp.net)。

解决方案 »

  1.   

    if(select.value='A'){
       A.style.display='';
       BC.style.display='none';
    }
    else if(select.value='B'){
       A.style.display='none';
       BC.style.display='';
    }
      

  2.   

    <select name=sel onchange="A(this.options[this.options.selectedIndex].value)">
    <option value="">请选择</OPTION >
    <option value="A">A</OPTION >
    <option value="B">B</OPTION >
    <option value="C">C</OPTION >
    </select>
    <script>
    function A(s)
    {
      if(s='A'){ 
      A.style.display=''; 
      BC.style.display='none'; 

    else if(s='B'){ 
      A.style.display='none'; 
      BC.style.display=''; 

    }}
    </script>
      

  3.   

    5楼的可以试试~~
    <select name=sel onchange="A(this.options[this.options.selectedIndex].value)"> 
    <option value="">请选择 </OPTION > 
    <option value="A">A </OPTION > 
    <option value="B">B </OPTION > 
    <option value="C">C </OPTION > 
    </select> 
    <script> 
    function A(s) 

      if(s='A'){ 
      A.style.display=''; 
      C.style.display='none'; 
      B.style.display='none'; 

    else if(s='B'){ 
      A.style.display='none'; 
      B.style.display=''; 
      C.style.display=''; 

    else if(s='C'){ 
      C.style.display='none'; 
      B.style.display=''; 
      A.style.display=''; 

    } } 
    </script> 
      

  4.   

    谢谢楼上的朋友。再问下,asp.net页面如何取得select的值?
      

  5.   

    谢谢楼上的朋友。再问下,asp.net页面如何取得select的值?
      

  6.   

    this.options[this.options.selectedIndex].value;
      

  7.   

    dropdownlist在生成的html里面就是select,
    要获得dropdownlist的值,可以是ddl.selectedvalue,ddl为dropdownlist的ID
    使用js的话
    this.options[this.options.selectedIndex].value;