<script type="text/javascript">
$(document).ready(function(){
    var param;
  $("#selall").click(function(){
  $("#year").attr("disabled",true);
  $("#period").attr("disabled",true);
  param="list";
  });
 
    $("#selyear").click(function(){
    $("#year").attr("disabled",false);
    $("#period").attr("disabled",true);
   
      });    $("#selperiod").click(function(){
    $("#year").attr("disabled",false);
    $("#period").attr("disabled",false);
   
      });      if(($("#year").attr("disabled")==true)&&($("#period").attr("disabled")==true)){
param ="list";
        }
      if(($("#year").attr("disabled")==false)&&($("#period").attr("disabled")==true)){
    param = $("#year").val();
    }
      if(($("#year").attr("disabled")==false)&&($("#period").attr("disabled")==false)){
      param = $("#year").val()+$("#period").val();
     }

$("#searchButton").click(function(){

alert(param);
//window.location.href="searchPlan.action?yp="+param;
});
});
</script>
<html>
<table>
<tr>
<td>
<select id="year">
<option value="2009">2009</option>
   </select>
<select id="period">
<option id="period" value="第一学期">第一学期</option>
   </select>
</td>
</tr>
<tr>
<td>
<input type="radio" name="select" id="selall">入学以来
<input type="radio" name="select" id="selyear">学年
<input type="radio" name="select" id="selperiod">学期
</td>
</tr>
</table>
</html>
我想实现选中 id=selall的单选框,让上边2个下拉全变灰,传一个参数param=list 到后台,如果选中id是selyear的单选,让学期下拉边灰,传学年下拉的value到后台,选中selperiod的单选,学年和学期下拉都不变灰,传给后台的参数是其组合值,这样写怎么老是实现不了,是不是逻辑有错啊,大大们帮帮忙!!!(少写了一个id为searchButton的button)

解决方案 »

  1.   

    第七行多了一句param="list";没删掉
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    <script src="jquery-1.3.2.js"></script>
    <script>
    $(document).ready(function(){
        var param;
    $("#selall").click(function(){
    $("#year").attr("disabled",true);
    $("#period").attr("disabled",true);
    param="list";
    });$("#selyear").click(function(){
    $("#year").attr("disabled",false);
    $("#period").attr("disabled",true);});$("#selperiod").click(function(){
    $("#year").attr("disabled",false);
    $("#period").attr("disabled",false);});if(($("#year").attr("disabled")==true)&&($("#period").attr("disabled")==true)){
    param ="list";
    }
    if(($("#year").attr("disabled")==false)&&($("#period").attr("disabled")==true)){
    param = $("#year").val();
    }
    if(($("#year").attr("disabled")==false)&&($("#period").attr("disabled")==false)){
    param = $("#year").val()+$("#period").val();
    }$("#searchButton").click(function(){alert(param);
    //window.location.href="searchPlan.action?yp="+param;
    });
    });
    </script>
    </head><body>
    <table>
    <tr>
    <td>
    <select id="year">
    <option value="2009">2009</option>
    </select>
    <select id="period">
    <option id="period" value="第一学期">第一学期</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>
    <input type="radio" name="select" id="selall">入学以来
    <input type="radio" name="select" id="selyear">学年
    <input type="radio" name="select" id="selperiod">学期
    </td>
    </tr>
    </table>
    </body>
    </html>
    在我这里其实没有什么问题