慕
慕荣冰靖
Unregistered / Unconfirmed
GUEST, unregistred user!
两 个页面:a1,b1.页面a1中有多个文本框module_no,mprice.(随记录多少而定).有一个carid文本框.点击一下按钮后打开另一个页面b1.里面有一个radiobutton,它的事件是onclick="getpic(num,pictype)".请问我写了以下的script怎么会有错误?
<script>
function getpic(num,pictype) //传递图片标题到表单module_no中
{
mod=opener.parent.form2.getElementsByName('module_no');
mpri=opener.parent.form2.getElementsByName('mprice');
for(i=0;i<mpri.length;i++)
{
with (opener.parent.form2)
{
switch (carid.value)
{
case "i+1":
mod.value=num;
mpri.value=pictype;
break;
}
}
}
}
</script>
但是如果我用各文本框有序号
function getpic(num,pictype)
{
with (opener.parent.form2)
{
switch (carid.value)
{
case "1":
opener.parent.form2.module_no1.value=num;
opener.parent.form2.mprice1.value=pictype;
break;
case "2":
opener.parent.form2.module_no2.value=num;
opener.parent.form2.mprice2.value=pictype;
break;
}
......
}
}
}
</script>
这样的话就行的,但我倒底有几个module_no,mprice不能确定,所以用循环,不知道怎么写?
<script>
function getpic(num,pictype) //传递图片标题到表单module_no中
{
mod=opener.parent.form2.getElementsByName('module_no');
mpri=opener.parent.form2.getElementsByName('mprice');
for(i=0;i<mpri.length;i++)
{
with (opener.parent.form2)
{
switch (carid.value)
{
case "i+1":
mod.value=num;
mpri.value=pictype;
break;
}
}
}
}
</script>
但是如果我用各文本框有序号
function getpic(num,pictype)
{
with (opener.parent.form2)
{
switch (carid.value)
{
case "1":
opener.parent.form2.module_no1.value=num;
opener.parent.form2.mprice1.value=pictype;
break;
case "2":
opener.parent.form2.module_no2.value=num;
opener.parent.form2.mprice2.value=pictype;
break;
}
......
}
}
}
</script>
这样的话就行的,但我倒底有几个module_no,mprice不能确定,所以用循环,不知道怎么写?