MyException - 我的异常网
当前位置:我的异常网» C# » 一个省份选择的js有关问题

一个省份选择的js有关问题

www.MyException.Cn,网友分享于:2013-01-01   浏览:65次
一个省份选择的js问题
<form   id= "Form1 "   method= "post "   runat= "server ">
<script   language= "javascript ">

function   provinceSelChange(selname)
{
var   index=Form1.Province.value;
pList.getOptionAreasString(index,selname);
}

function   area(name,code)  
{
      this.name=name;
      this.code=code;
       
}

function   province(name,code)  
{
      this.data=new   Array();
      this.name=name;
      this.code=code;
      this.add=area_add;
     
}

function   provinceList()  
{
      this.data=new   Array();
      this.add=province_add;
      this.addAt=province_addAt;
      this.getOptionString=provinceList_getOptionString;
      this.getOptionAreasString=provinceList_getAreasOptionString;
}

function   area_add(area)
{
this.data[this.data.length]=area;
}
function   province_add(province)
{
this.data[this.data.length]=province;
}
function   province_addAt(i,area)
{
var   province=this.data[i];
province.add(area);
}
function   provinceList_getOptionString()
{
var   temp= " ";
for(var   i=0;i <this.data.length;i++)
temp+= " <option   value= "+i+ "> "+this.data[i].name;
return   temp;
}
function   provinceList_getAreasOptionString(index,selname)
{
var   temp= " ";
var   prov=this.data[index];

if(prov==null||prov.data.length==0)
{
selname.length=1;  
selname.options[0].text= "没有城市 ";
selname.options[0].value= "no ";
return   " <option   value=no> 没有城市   </option> ";
}
selname.length=0;
for(var   i=0;i <prov.data.length;i++)
{
selname.length++;
selname.options[i].text=prov.data[i].name;
selname.options[i].value=prov.data[i].code;
temp+= " <option   value= "+prov.data[i].code+ "> "+prov.data[i].name;
}
return   temp;
}
var   pList=new   provinceList();
</script>
<script   language= "javascript ">
pList.add(new   province( "山西 ",   "山西 "));
pList.addAt(0,new   area( "朔州 ",   "203 "));
pList.addAt(0,new   area( "怀仁 ",   "204 "));
pList.addAt(0,new   area( "应县 ",   "205 "));
pList.addAt(0,new   area( "右玉 ",   "206 "));
pList.addAt(0,new   area( "山阴 ",   "207 "));
pList.addAt(0,new   area( "忻州 ",   "208 "));
pList.addAt(0,new   area( "原平 ",   "209 "));
pList.add(new   province( "新疆 ",   "新疆 "));
pList.addAt(1,new   area( "塔城 ",   "2207 "));
pList.addAt(1,new   area( "额敏 ",   "2208 "));
pList.addAt(1,new   area( "裕民 ",   "2209 "));
pList.addAt(1,new   area( "托里 ",   "2210 "));
pList.addAt(1,new   area( "哈密 ",   "2211 "));
相关解决方案
  • 暂无相关解决方案
软件开发程序错误异常ExceptionCopyright © 2009-2014MyException 版权所有