Home  >  Article  >  Web Front-end  >  Javascript value transfer implementation code between two forms_javascript skills

Javascript value transfer implementation code between two forms_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:45:44869browse

For example, we create a new form FatherPage.htm:
XML-Code:

Copy the code The code is as follows:





In fact, while opening the subform, we can also assign values ​​to the elements of the subform, because the window.open function will also return a reference to the subform, so FatherPage.htm can be modified to:
XML-Code:
Copy code The code is as follows:





By judging whether the reference of the subform is empty, we can also control it to open only one subform. Form:
XML-Code:
Copy code The code is as follows:

< script type="text/javascript">
var child
function OpenChildWindow()
{
if(!child)
child = window.open('ChildPage.htm');
child.document.getElementById('txtInput').value
=document.getElementById('txtInput').value;
}




That alone is not enough , when closing the child form, the child variable of the parent form must also be cleared, otherwise the child form cannot be reopened after it is opened and then closed:
XML-Code:
Copy code The code is as follows:



< ;input type="text" id="txtInput" />


Statement:
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