父页面调用内嵌iframe页面表单里的值

xiaoxiaowoxing 2005-10-07 10:32:12
在a.htm:
<iframe src="bgpic.asp" id="llll" name="llll" scrolling="auto" allowtransparency="true" frameborder="0" height="100" width="100%"></iframe>

function getFrameValue()
{
document.wishwrite.bgpic.value=document.llll.bgpicform.bgpic.value;;
document.wishwrite.bgmusic.value="../wishmusic/hahan.rm";
return true;
}
<form name="wishwrite" method="post" action="show.asp" onSubmit="return getFrameValue();“>
在bgpic.asp:
<form name="bgpicform" action="" method="get"><INPUT id="bgpic" type=radio value="<%= rs("picurl")%>" name="bgpic"> </form>

结果在a.htm 提交的时候 bgpic 取到的值:undefined
...全文
341 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoxiaowoxing 2005-10-09
  • 打赏
  • 举报
回复
问题已解决,最后的改动是把function getFrameValue()改成我上一次贴的那个函数,已测试成功,感谢各位!!!
xiaoxiaowoxing 2005-10-09
  • 打赏
  • 举报
回复
关键是:文本框和单选按钮组(数量不定)的不同
function getFrameValue(){
var obj=llll.document.all.bgpic;
var objLen=obj.length;
var theValue="";
for(i=0;i<objLen;i++){
if(obj[i].checked)
theValue=obj[i].value;
}
var obj2=ssss.document.all.bgmusic;
var objLen2=obj2.length;
var theValue2="";
for(i=0;i<objLen2;i++){
if(obj2[i].checked)
theValue2=obj2[i].value;
}
document.wishwrite.bgpic.value=theValue;
document.wishwrite.bgmusic.value=theValue2;
}
xiaoxiaowoxing 2005-10-08
  • 打赏
  • 举报
回复
这和机器的设置有关系吗?
xiaoxiaowoxing 2005-10-08
  • 打赏
  • 举报
回复
function getFrameValue()
{
var frm=document.frames["llll"];
ss=frm.document.bgpicform.bgpic.value;
alert(ss);
return false;
}
我是这么测试的,测试结果弹出undefined

石头子 2005-10-08
  • 打赏
  • 举报
回复
我试过了,这样是没问题的........................

<iframe src="t2.htm" id="llll" name="llll" scrolling="auto" allowtransparency="true" frameborder="0" height="100" width="100%"></iframe>
<script language="javascript">
function getFrameValue()
{
document.wishwrite.bgpic.value=document.llll.bgpicform.bgpic.value;
document.wishwrite.bgmusic.value="../wishmusic/hahan.rm";

return false;
}
</script>
<form name="wishwrite" method="post" action="show.asp" onSubmit="return getFrameValue();">
<input type="text" name="bgmusic">
<input type="text" name="bgpic">
<input type="submit" name="btt" value="OK ... ">
</form>





在bgpic.asp:

<form name="bgpicform" action="" method="get">
<INPUT id="bgpic" type=radio value="test" name="bgpic">
</form>
cadust 2005-10-08
  • 打赏
  • 举报
回复
document.wishwrite.bgpic.value=document.llll.bgpicform.bgpic.value;

TO

document.wishwrite.bgpic.value=document.frames("llll").bgpicform.bgpic.value;
LZDGDX 2005-10-08
  • 打赏
  • 举报
回复
顶一下
xiaoxiaowoxing 2005-10-07
  • 打赏
  • 举报
回复
我按照smallyear说的做了,现在 bgpic 的值 还是:undefined
这和机器的设置有没有关系
dh20156 2005-10-07
  • 打赏
  • 举报
回复
这样可以得到值,参考:
t.htm
<iframe src="bgpic.htm" id="llll" name="llll" scrolling="auto" allowtransparency="true"

frameborder="0" height="100" width="100%"></iframe>
<script language="javascript">
function getFrameValue()
{
document.wishwrite.bgpic.value=document.llll.bgpicform.bgpic.value;
return false;
}
</script>
<form name="wishwrite" method="post" action="show.asp" onSubmit="return getFrameValue();">
<INPUT id="bgpic" type=text name="bgpic">
<input type="submit">
</form>

bgpic.htm
<form name="bgpicform" action="" method="get"><INPUT id="bgpic" type=text value="aaa" name="bgpic"> </form>
smallyear 2005-10-07
  • 打赏
  • 举报
回复
访问页面中IFRAME中的元素,不能直接使用ID,例:
var frm=document.frames["llll"];
document.wishwrite.bgpic.value=frm.document.bgpicform.bgpic.value;;
document.wishwrite.bgmusic.value="../wishmusic/hahan.rm";
z2600324 2005-10-07
  • 打赏
  • 举报
回复
看看http://www.lepoo.net好了!!!
xiaoxiaowoxing 2005-10-07
  • 打赏
  • 举报
回复
我的QQ:107956657
解决问题的第一时间给分

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧