62,067
社区成员
发帖
与我相关
我的任务
分享
function fillDll(city)
{
document.getElementById("DropDownList1").options.length=0;
var indexofcity;
var scity; //这里不能是city和上面重名,这里应该是区的意思;
//切割传递来的字符串
//debugger
while(city.length>0)
{
//判断是否是最后一个字符串
indexofcity=city.indexOf(",");
if(indexofcity >0)
{
scity=city.substring(0,indexofcity);
city=city.substring(indexofcity+1);
//填充下拉框
document.getElementById("DropDownList1").add(new Option(scity,scity));
}
else
{
// 如果是最后一个字符串
document.getElementById("DropDownList1").add(new Option(city,city));
break;
}
};
<script type="text/javascript">
function FillData()
{
var city=document.getElementById('<%=TextBox1.ClientID %>').value;
<%= ClientScript.GetCallbackEventReference(this, "city", "fillDll", null,true)%>;
}
function fillDll(city)
{
document.getElementById('<%=DropDownList1.ClientID %>').options.length=0;
var indexofcity;
var tempCity;
//切割传递来的字符串
while(city.length>0)
{
//判断是否是最后一个字符串
indexofcity=city.indexOf(",");
if(indexofcity >0)
{
tempCity=city.substring(0,indexofcity);
city=city.substring(indexofcity+1);
//填充下拉框
document.getElementById('<%=DropDownList1.ClientID %>').add(new Option(tempCity,tempCity));
}
else
{
// 如果是最后一个字符串
document.getElementById('<%=DropDownList1.ClientID %>').add(new Option(city,city));
break;
}
};
}
</script>