<script language=javascript>
function SearchTypeClick(i){//alert(i);
switch(i)
{
case "0":
document.all["divSrh1"].style.display ="";
document.all["divSrh2"].style.display ="none";
    break;
default:
document.all["divSrh1"].style.display ="none";
document.all["divSrh2"].style.display ="";
   break;
}
}
</script>

解决方案 »

  1.   

    <body>
     <table class="font-default" cellSpacing="0" cellPadding="0" width="610" border="0">
    <tr>
    <td vAlign="bottom" width="88"><input id="srh_type" onclick="SearchTypeClick('0');" type="radio" value="0" CHECKED name="srh_type">
    城市</td>

    <td vAlign="bottom" width="105"><input id="srh_type" onclick="SearchTypeClick('1');" type="radio" value="1" name="srh_type">
    景区</td>

    </tr>
    </table>

    <div id="divSrh1" style="DISPLAY: ">
    <table width='610' border='0' cellspacing='0' cellpadding='0' class='font-default'>
    <tr>
    <td width='590'><label style='MARGIN-LEFT:5px'><strong>选择城市</strong></label></td>
    </tr>
    </table></div><div id="divSrh2" style="DISPLAY: none">
    <table width='610' border='0' cellspacing='0' cellpadding='0' class='font-default'>
    <tr>
    <td width='590'><label style='margin-left:5px '><strong>输入景区</strong></label></td>
    </tr>
    </table></div> </body>
    </html>
      

  2.   

    方法这样写
    function SearchTypeClick(i){
    switch(i){
    case "0":
    document.all["divSrh1"].style.display ="";
    document.all["divSrh2"].style.display ="none";
    break;
    case "1":
    document.all["divSrh1"].style.display ="none";
    document.all["divSrh2"].style.display ="";
    break;
    }
    }调用的时候这样写
    onclick="SearchTypeClick(this.value);"
      

  3.   

    function SearchTypeClick(a){
    var i=a.value;
    alert(i);if(i==0){
        document.all["divSrh2"].style.display ="none";
    document.all["divSrh1"].style.display ="block";}else if(i==1){
    document.all["divSrh1"].style.display ="none";
    document.all["divSrh2"].style.display ="block";
    }
    }
      

  4.   

    谢谢各位,原来是我js中function的参数有问题,感谢大家,马上给分!