日期:2014-05-18  浏览次数:20454 次

这个有关二级联动的代码,怎么将它放入.js文件中。然后引用它啊。。
<script   language= "javascript "   type= "text/javascript ">
//城市------------------------------
function   cityResult()  
{  
var   city=document.getElementById( "DropDownList1 ");
AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
}

function   get_city_Result_CallBack(response)
{
if   (response.value   !=   null)
{
document.all( "DropDownList2 ").length=0;
//document.all( "DropDownList2 ").options[0]=new   Option( '请选择 ', ' ');
     var   ds   =   response.value;
if(ds   !=   null   &&   typeof(ds)   ==   "object "   &&   ds.Tables   !=   null)
{
for(var   i=0;   i <ds.Tables[0].Rows.length;   i++)
     {
     var   name=ds.Tables[0].Rows[i].city;
              var   id=ds.Tables[0].Rows[i].cityID;
       document.all( "DropDownList2 ").options.add(new   Option(name,id));
     }
}
}
return
}
// function   areaResult()  
// {  
// var   area=document.getElementById( "DropDownList2 ");
// AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack);
// }
function   getData()
{
var   province=document.getElementById( "DropDownList1 ");
var   pindex   =   province.selectedIndex;
var   pValue   =   province.options[pindex].value;
var   pText     =   province.options[pindex].text;

var   city=document.getElementById( "DropDownList2 ");
var   cindex   =   city.selectedIndex;
var   cValue   =   city.options[cindex].value;
var   cText     =   city.options[cindex].text;
}
</script>

------解决方案--------------------
<script language=javascript src= "js1111.js "> </script>

onMouseOver = "cityResult() " ....