SoFunction
Updated on 2025-02-28

Data transfer code between Javascript forms

1. The easiest thing is to pass data on the form on the same web page.
For example, there are two forms on a web page, each form has a text box and a button. Click the button to operate the value of the other party's text box opposite each other. The example we give is to pay one text box to another. The specific HTML code is as follows:
Copy the codeThe code is as follows:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form name="form1" method="post" action="">
<input type="text" name="textfield">
<input type="button" name="Submit" value="1---------&gt;2" onClick="ok()">
</form>
<form name="form2" method="post" action="">
<input type="text" name="textfield2">
<input type="button" name="Submit" value="2-----&gt;1" onClick="ok1()">
</form>
</body>
</html>

The above is HTML code. You may have noticed the code of onclik. There are two functions, and the next is the code of JAVASCRIPT:
Copy the codeThe code is as follows:

<script language="JavaScript">
function ok()
{
document.form2.=document.;
}
function ok1()
{
document.=document.form2.;
}
</script>

Second, the second is the data transfer between the text boxes of the form between two windows. In fact, this can be expanded on the original basis. I won’t talk about how to create a pop-up window and the code of the form in the form. I will now talk about how to operate the data of the text box in the form of the parent window. The specific code is as follows:
Copy the codeThe code is as follows:

<script language="JavaScript">
function ok()
{
.form2.=document.
}
</script>

Third, the third type is the data transmission between the text boxes of the form between the frame web pages.
The point to note is how the frame is written:
Copy the codeThe code is as follows:

<frameset cols="505,505">
<frame src="" name="leftr" >//Define the name of the frame
<frame src="" name="right">
</frameset>
<noframes><body>
</body></noframes>

The specific implementation code is as follows:
Copy the codeThe code is as follows:

<script language="JavaScript">
function ok()
{
.form2.
=document.
}
</script>

These three simple methods of interoperating text boxes between the three windows are realized, and the other things that need to be paid attention to are their relationship.