<SCRIPT LANGUAGE=JavaScript>
function hide(var s) {
 document.getElementById(s).style.display = "none";
}
function show(var s) {
  document.getElementById(s).style.display = "block";
}
</SCRIPT>

 <select class=input  name='s1' id='s1'>               
                  <option value="1" onClick="hide('flight5');show('flight4');">按航班号</option>
                  <option value="2" onClick="hide('flight4');show('flight5');">按城市</option>
                </select>

 <div  style="display:block;" id="flight4">
       <table  width="100%">

</table>
</div>
<div  style="display:none;" id="flight5">
       <table  width="100%">

</table>
</div>
我是想实现当选择“按航班号”时显示“flight4”,选择“按城市”时,显示“flight5”。

解决方案 »

  1.   

    whzresponse() :您能说明白点么?
      

  2.   

    select 的 option项没有onclick函数,而是select本身有onchange函数  这一点你要明白
      

  3.   


     object.style.visibility="visible" or "hidden"
      来替换object.style.display = "none" or "block"
     就可以实现你要求的效果.我就是这样实现的
      

  4.   

    <script language=JavaScript>
    function hide(s) {  document.getElementById(s).style.display = "none";
     
    }
    function show(s) {
      document.getElementById(s).style.display = "block";
    }
    function changeValue(value1){

     if(parseInt(value1)==1) {
      hide('flight5');
      show('flight4');
      }else if(parseInt(value1)==2){
      hide('flight4');
      show('flight5');
     }

    }
    </script>
    <html>
    <head></head>
    <body>
     <select name='s1' id='s1' onchange="changeValue(this.options[selectedIndex].value)">               
                      <option value="1" >按航班号</option>
                      <option value="2" >按城市</option>
     </select>
     <div  style="display:block;" id="flight4">
           <table  width="100%">
                </table>
     </div>
    <div  style="display:none;" id="flight5">
           <table  width="100%">
         
           </table>
    </div>
    </body>
    </html>