ねもぷらす

ふぁいんでぃんぐねもの日記。プログラミングとか育児とか

親子の再会

  • 結果を別窓に表示する
<html>
<head>
<script Language="Javascript">
<!--
function newWindow()
  {
    document.forms[0].target = "result";   // こういう書き方も出来たと
    document.forms[0].action = "test.cgi"; // 思い出しました。。
    window.open('','result','scrollbars')
  }
-->
</script>
</head>
<body>
<form  name="test" action="test.cgi" method="GET">
<input type="text" name="key">
<input type="submit" value="表示" onclick='newWindow()'></td>
</form>
</body>
</html>
  • 親子フォーム間での値の受け渡し
    • 親フォーム
<html>
<head>
</head>
<body>
<form name="parent">
[<a href="child.htm" target="_blank">別窓に表示</a>]
<input type="text" name="p_code">
</form>
</body>
</html>
    • 子フォーム
<html>
<head>
<script language="JavaScript">
<!--
function toParent()
  {
    dt = document.child.c_code.value;
    window.opener.document.parent.p_code.value = dt;
    window.close();
  }
//-->
</script>
</head>
<body>
<form name="child">
<input type="text" name="c_code">
<input type="button" onClick="toParent()" value="送信">
</form>
</body>
</html>