小弟才接触.net对联动不是很熟悉,使用XML做数据源的联动。无法给dropdownlist赋值!
我使用的是网上的DropDownList联动的例子(c#) 改写的。地区联动显示。
现在只有一个问题是,第二个DropDownList没有办法控制默认显示。
代码如下:前台
<script language= "javascript ">
var Wantcount;
var Groupcount;
Groupcount=0;
Group = new Array();
<asp:Literal id= "Want " runat= "server "> </asp:Literal>
function changelocation1(locationid)
{
document.submit.DirectionList1.length = 0;
var locationid=locationid;
var i;
var flag;
var j;
for (i=0;i <Groupcount; i++)
{
if (Group[i][0] == locationid)
{
flag = true;
for (j =0;j <document.submit.DirectionList1.length;j++)
if (document.submit.DirectionList1[j].value == Group[i][1])
{
flag = false;
break;
}
if (flag)
document.submit.DirectionList1.options[document.submit.DirectionList1.length]
= new Option(Group[i][1], Group[i][1]);
}
}
}
function changelocation11(locationid, direction)
{
}
</script>
<body id= "body_acc " ms_positioning= "GridLayout ">
<form id= "submit " method= "post " runat= "server ">
<table width= "950 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " id= "my ">
<tr>
<td align= "center " bgcolor= "333333 "> <!--#include file= "bar.aspx "--> </td>
</tr>
</table> <tr> <td height=25 vAlign=bottom bgcolor= "#FFFFFF "> 地区: </td>
<td bgcolor= "#FFFFFF "> <asp:dropdownlist id= "SourceList1 " runat= "server " DataTextField= "v_source " DataValueField= "v_source " onchange= "changelocation1(document.submit.SourceList1.options[do