Home > Web Front-end > JS Tutorial > body text

How to implement JS to pass value to form in iframe

黄舟
Release: 2017-03-25 14:44:46
Original
1512 people have browsed it

This article mainly introduces the method of JS to transfer values ​​​​to forms in iframes, involving js related implementation techniques for page elements and form attribute operations. Friends in need can refer to the following

The examples in this article describe JS Implement the method of passing values ​​to the form in the iframe. Share it with everyone for your reference, the details are as follows:

Add the contentWindow attribute to the iframe before assigning the value. Test everything in IE and firefox and everything is ok.

For example:

Page a .jsp

<script language="Javascript">
function ExecuteSql()
{
var FormObj = document.getElementById("ResultShowFrame").contentWindow;
var SqlStr=document.getElementById("sqlcontent").value;
if (SqlStr !="")
{
  FormObj.document.getElementById("Sql").value=SqlStr;
  FormObj.document.getElementById("Result").value=&#39;Submit&#39;;
  FormObj.document.ExecuteForm.submit();
}
}
</script>
<form name="dbcompress" action="?Action=CompressDate" method="post">
<textarea name="sqlcontent" rows="3" wrap="OFF" style="width:100%;" id="sqlcontent"></textarea>
<input name="Submit" type="button" onClick="ExecuteSql();" class="Anbut2"  value=" 执 行 ">
</form>
<iframe id="ResultShowFrame" scrolling="yes" src="b.asp" style="width:100%;height:420;" frameborder=1></iframe>
Copy after login

Page b.jsp:

<form name="ExecuteForm" method="post" action="">
  <input type="hidden" name="Sql" id="Sql">
  <input type="hidden" name="Result" id="Result">
</form>
Copy after login

The above is the detailed content of How to implement JS to pass value to form in iframe. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!