jquery  
//填数据
function ddlSmallType()
{alert('aaa');
  $("#ddlSmallType").html("");
  $("#ddlSmallType").append("<option value='0' selected='selected'>==请选择==</option>");  var strId=$("#ddlBigType option[selected]").attr("value");  if(strId!=0)
  {
  $.getJSON("ddlSmallType.aspx?Id="+strId, function (data) {
  for (var i = 0; i < data.length; i++) {
  $("#ddlSmallType").append($("<option></option>").val(data[i].ID).html(data[i].Cname));
  };
  });
  }
  // $("#ddlSmallType").focus();
}
$(document).ready(function(){
  $("#ddlBigType").change(function () { ddlSmallType(); });//添加事件   
    
  $("#ddlSmallType").change(function () { document.getElementById("hdfSmallType").value=$("#ddlSmallType option[selected]").attr("value");});//添加事件  
      $("#ddlSmallType").val(0);$.formValidator.initConfig({formid:"form1",onerror:function(msg){alert(msg.replace(/<[^>]+>/g,""));return  false;},onsuccess:function(){return true;}});$("#ddlBigType").formValidator({onshow:"<font color=\"999999\">请选择行业大类。</font>",onfocus:"所在行业大类必须选择",oncorrect:"谢谢你的配合"}).inputValidator({min:1,onerror: "你是不是忘记选择行业大类!"});
$("#ddlSmallType").formValidator({onshow:"<font color=\"999999\">请选择行业小类。</font>",onfocus:"所在行业小类必须选择",oncorrect:"谢谢你的配合"}).inputValidator({min:1,onerror: "你是不是忘记选择行业小类!"});});
存在 问题
select ddlSmallType中数据重复出现二次ddlSmallType 中 alert('aaa'); 执行二次与formValidator 冲突
动态$.getJSON 的数据时默认为select ddlSmallType中数据选择的是最后一条数据  入加上 $("#ddlSmallType").focus(); select ddlSmallType中数据重复出现二次

解决方案 »

  1.   

    这样呢?function ddlSmallType(){
    alert('aaa');
      var strId=$("#ddlBigType option[selected]").attr("value");
      if(strId!=0){
        $.getJSON("ddlSmallType.aspx?Id="+strId, function (data) {
          $("#ddlSmallType").length=0;
          $("#ddlSmallType").append("<option value='0' selected='selected'>==请选择==</option>");
          for (var i = 0; i < data.length; i++) {
            $("#ddlSmallType").append($("<option></option>").val(data[i].ID).html(data[i].Cname));
          };
        });
      }
      // $("#ddlSmallType").focus();
    }
      

  2.   


    function ddlSmallType(){
    alert('aaa');
      var strId=$("#ddlBigType option[selected]").attr("value");
      if(strId!=0){
        $.getJSON("ddlSmallType.aspx?Id="+strId, function (data) {
          $("#ddlSmallType").length=0;
          $("#ddlSmallType").append("<option value='0' selected='selected'>==请选择==</option>");
          for (var i = 0; i < data.length; i++) {
            $("#ddlSmallType").append($("<option></option>").val(data[i].ID).html(data[i].Cname));
          };
        });
      }
      // $("#ddlSmallType").focus();
    }
      

  3.   

    问题解决了 没必要验证
    //$("#ddlBigType").formValidator({onshow:"<font color=\"999999\">请选择行业大类。</font>",onfocus:"所在行业大类必须选择只验证小类