D1_path应该是你的<select>吧,如果你只有一个就不能这么用了,
如果有多个,把所有的
< select id=D1_path...>...
< select id=D1_path...>...
< select id=D1_path...>...
< select id=D1_path...>...
这样做就可以用了.
对了还有,好像js只有传对象和传值,没有引用,至少叫作传对象肯定没错,引用就不敢说了。
如果有多个,把所有的
< select id=D1_path...>...
< select id=D1_path...>...
< select id=D1_path...>...
< select id=D1_path...>...
这样做就可以用了.
对了还有,好像js只有传对象和传值,没有引用,至少叫作传对象肯定没错,引用就不敢说了。
{
id2=id*1+1
eval("Form1.Dl_path"+id).options.length=0;
eval("Form1.Dl_path"+id).options.length ++ ;
eval("Form1.Dl_path"+id2).options[Form1.Dl_path2.options.length-1].text="";
eval("Form1.Dl_path"+id2).options[Form1.Dl_path2.options.length-1].value="";
{
Form1["Dl_path"+id].options.length=0;
Form1["Dl_path"+id].options.length ++ ;
Form1["Dl_path"+(id+1)].options[Form1.Dl_path2.options.length-1].text="";
Form1["Dl_path"+(id+1)].options[Form1.Dl_path2.options.length-1].value="";
我的页面中有很多<select>,它们的名字分别为:dl_path1、dl_path2、dl_path3....
我想在js中控制它们做一些同样的事情,但是由于它们所存储的数据不同所以想写一个函数。比如说:我选择dl_path1,dl_path2就根据1的选择做一些自身的选择;
我选择dl_path2,dl_path3就根据2的选择做一些自身的选择;
我选择dl_path3,dl_path4就根据3的选择做一些自身的选择
.
.
.
所以怎样能把这样的编号传到dl_path后面来代表该控件呢?请再帮忙
{
document.getElementById("Dl_path" + id).options.length=0;
document.getElementById("Dl_path" + id).options.length ++ ;
document.getElementById("Dl_path" + (id+1)).options[Form1.Dl_path2.options.length-1].text="";
document.getElementById("Dl_path" + (id+1)).options.length-1].value="";
}
也可寫成這樣:
document.Form1.elements["Dl_path" + id].options.length=0;
document.Form1.elements["Dl_path" + id].options.length ++ ;
...........