+ -
当前位置:首页 → 问答吧 → 请教高手ASP中怎样调用JS中的函数实现省市菜单关联

请教高手ASP中怎样调用JS中的函数实现省市菜单关联

时间:2011-08-10

来源:互联网

Js文件:
function setsquare(Square) {
  switch (document.addDataForm["Area"].value) {
  case "北京" :
  var squareOptions = new Array(
  "东城", "东城",
  "西城", "西城",
  "崇文", "崇文",
  "宣武", "宣武",
  "朝阳", "朝阳",
  "丰台", "丰台",
  "石景山", "石景山",
  "海淀", "海淀",
  "门头沟", "门头沟",
  "房山", "房山",
  "通州", "通州",
  "顺义", "顺义",
  "昌平", "昌平",
  "大兴", "大兴",
  "平谷", "平谷",
  "怀柔", "怀柔",
  "密云", "密云",
  "延庆", "延庆");
  。。。。。。。。。。部分省略
  break;
  default:
  var squareOptions = new Array("", "");
  break;
  }

document.addDataForm["Square"].options.length = 0;  
for(var i = 0; i < squareOptions.length/2; i++) {
document.addDataForm["Square"].options[i]=new Option(squareOptions[i*2],squareOptions[i*2+1]);

if (document.addDataForm["Square"].options[i].value==Square) 
{
//alert("here put Square ok!");
document.addDataForm["Square"].selectedIndex = i;
}
}
}

function initAS(Area,Square) {
var provObject = document.addDataForm["Area"];
  for(var i = 0; i < document.addDataForm["Area"].options.length; i++) {
  if (document.addDataForm["Area"].options[i].value==Area)
  {
  //alert("prov put is ok");
  document.addDataForm["Area"].selectedIndex = i;
  }
  }
  setsquare(Square);
}
ASP文件:
<select onChange="setsquare();" name='Area' style="width:90px;" class="int">
  <option value='北京'>北京</option></select>
  <select name='Square' style="width:90px;" class="int"></select>
  <script src="../images/getcity.js"></script>
  <script>initAS('','');</script>
这样写哪里错了 应该怎样写?

作者: yuanlovefeng1314   发布时间: 2011-08-10

有木有人啊!!!!!!????????

作者: yuanlovefeng1314   发布时间: 2011-08-12

<select onChange="setsquare();" name='Area' style="width:90px;" class="int">

==>

<select onChange="setsquare(this);" name='Area' style="width:90px;" class="int">

好像是少了参数,试下

作者: yuxh81   发布时间: 2011-08-12