<frameset cols="25%,75%">
<frame id="frmQueryCondition" src=TeacherQuery/TeacherQueryCondition.aspx>
<frame id="frmQueryResult" src=TeacherQuery/TeacherQueryResult.aspx>
</frameset>
将TeacherQueryCondition.aspx中的asp:TextBox和asp:Button换成<input type=text id="nptQueryCondition">和<input type=button>
在TeacherQueryResult.aspx中添加<asp:textbox id="txtTeacherIDorName" runat="server" Width="96px" ReadOnly="True"></asp:textbox>
在TeacherQueryCondition.aspx中添加如下脚本:
<script language="javascript">
//生成SQL语句
function Query()
{
var str = document.getElementById("nptQueryCondition").value;
parent.frames["frmQueryResult"].document.getElementById("txtTeacherIDorName").value= str;
parent.frames["frmQueryResult"].document.forms["Form1"].submit();
}
</script>
这样一来,当用户点击<input type=button>时,<asp:textbox id="txtTeacherIDorName" runat="server" Width="96px" ReadOnly="True"></asp:textbox>就得到了<input type=text id="nptQueryCondition">的value。
<frame id="frmQueryCondition" src=TeacherQuery/TeacherQueryCondition.aspx>
<frame id="frmQueryResult" src=TeacherQuery/TeacherQueryResult.aspx>
</frameset>
将TeacherQueryCondition.aspx中的asp:TextBox和asp:Button换成<input type=text id="nptQueryCondition">和<input type=button>
在TeacherQueryResult.aspx中添加<asp:textbox id="txtTeacherIDorName" runat="server" Width="96px" ReadOnly="True"></asp:textbox>
在TeacherQueryCondition.aspx中添加如下脚本:
<script language="javascript">
//生成SQL语句
function Query()
{
var str = document.getElementById("nptQueryCondition").value;
parent.frames["frmQueryResult"].document.getElementById("txtTeacherIDorName").value= str;
parent.frames["frmQueryResult"].document.forms["Form1"].submit();
}
</script>
这样一来,当用户点击<input type=button>时,<asp:textbox id="txtTeacherIDorName" runat="server" Width="96px" ReadOnly="True"></asp:textbox>就得到了<input type=text id="nptQueryCondition">的value。
本文介绍了一个使用JavaScript实现的跨iframe数据传递方案。用户在输入框中输入的内容可以通过按钮触发事件,将输入值传递到另一个iframe中的只读文本框,并触发表单提交。此方法适用于需要在不同iframe间进行简单数据交换的场景。
2495

被折叠的 条评论
为什么被折叠?



