1. JavaScript是在客户端运行的,在里面定义的变量不能直接返回到服务器端。你可以试试把JavaScript的值放到一个控件里面,然后在服务器端的代码里读取这个控件。服务器端的变量到可以很方便的传递到JavaScript中,一个方法也是用控件来传递,另一个直接的方法是输出一段JavaScript代码:Response.Write("<script language=JavaScript>var i; i="+i.ToString()+";</script>");
2. 把值传递到对话框窗体,可以通过URL或者其他参数来实现。对话框窗体可以通过window.opener来访问原窗体的控件和变量。
2. 把值传递到对话框窗体,可以通过URL或者其他参数来实现。对话框窗体可以通过window.opener来访问原窗体的控件和变量。
<script language="javascript">
<!--
function chg_SelTwo(a)
{
<%
Dim dsxml As New Data.DataSet()
dim i=0,j=0,k=0
dsxml.ReadXml(Server.MapPath("..") & "//settings//xml//DeviceList.xml")
'dsxml.Tables(1)
for i=0 to dsxml.tables(0).Rows.Count-1
response.write ("var a" & i & "=new Array(50);")
k=0
for j=0 to dsxml.tables(1).Rows.Count-1
if dsxml.Tables(1).Rows(j).Item("Class_Id")=i then
response.write("a" & i & "[" & k & "]='" & dsxml.Tables(1).Rows(j).Item("name") & "';")
k=k+1
end if
next
next
for i=0 to dsxml.tables(1).Rows.Count-1
response.write ("var b" & i & "=new Array(50);")
k=0
for j=0 to dsxml.tables(2).Rows.Count-1
if dsxml.Tables(2).Rows(j).Item("SubClass_Id")=i then
response.write("b" & i & "[" & k & "]='" & dsxml.Tables(2).Rows(j).Item("name") & "';")
k=k+1
end if
next
next
%>
var selected_id,name_arry,selected_id1,name_arry1,i;
selected_id=document.Form1.DropDownList14.selectedIndex;
//selected_id1=document.Form1.DropDownList15.selectedIndex;
if(selected_id < 0) selected_id = 0;
if(selected_id1 < 0) selected_id1 = 0;
name_array='a' + selected_id ;
//name_array1='a' + selected_id ;
var array_length=eval(name_array).length;
document.Form1.DropDownList15.Enabled=true;
if((a=="abc") && (document.Form1.DropDownList16.value=="" ))
return(true) ;
if (a=='null')
{
document.Form1.DropDownList15.length=0;
if (array_length==0)
{
document.Form1.DropDownList15.options[0]=new Option("该设备没有小类","");
}
else
{
//document.Form1.DropDownList15.options[0]=new Option("--请选择--","");
for (i=0; i < array_length ; i++)
{
if(eval(name_array)[i]!=null)
document.Form1.DropDownList15.options[i]=new Option(eval(name_array)[i],eval(name_array)[i]);
}
}
document.Form1.DropDownList15.selectedIndex = 0;
}
else
{
selected_id1=document.Form1.DropDownList15.selectedIndex;
var number=0;
for(i=0;i<selected_id;i++)
{
name_array='a' + i;
for(var j=0;j< array_length ;j++)
if(eval(name_array)[j]!=null)
{
number++;
}
}
number=number+selected_id1;
name_array1="b"+ number;
array_length=eval(name_array1).length;
document.Form1.DropDownList16.length=0;
if (array_length==0)
{
document.Form1.DropDownList16.options[0]=new Option("","该设备没有小类");
}
else
{
for (i=0;i < array_length ; i++)
{ if(i==0)
{if(eval(name_array1)[0]==null)
{
for (i=0;i < array_length ; i++)
if(eval(name_array1)[i]!=null)
document.Form1.DropDownList16.options[i]=new Option('','');
}
}
if(eval(name_array1)[i]!=null)
document.Form1.DropDownList16.options[i]=new Option(eval(name_array1)[i],eval(name_array1)[i]);
}
//document.Form1.DropDownList16.selectedIndex = 0;
}
}
}// -->
</script>