親ページのidを参照する方法
親ページのidを参照できるようにするには、iframe内の新規追加ボタンで親ページのidが参照できるように以下のように編集する。
- <form>エレメントにname='select_form'を加える
- idデータが参照できるように<input>エレメントにする
<form method='POST' action='./index.cgi' name='select_form'> ... <td>ID</td><td> <xsl:element name='input'> <xsl:attribute name='type'>text</xsl:attribute> <xsl:attribute name='readonly'>readonly</xsl:attribute> <xsl:attribute name='name'>id</xsl:attribute> <xsl:attribute name='value'><xsl:value-of select='id' /></xsl:attribute> </xsl:element> </td> ...
ページのロード時に親ページのデータを参照できるようにする。
<script type="text/javascript"> window.onload = function() { document.insert_form.plan_id.value = parent.document.select_form.id.value; } </script>
または、以上のように編集すれば、iframeページから親ページのidデータが参照できるようになる。
例えば、iframe内のページには以下のように編集する。
ここでは、新規追加ボタンに親ページのidをパラメータとして渡す。
... <xsl:element name='input'> <xsl:attribute name='type'>button</xsl:attribute> <xsl:attribute name='name'>insertbutton</xsl:attribute> <xsl:attribute name='value'>new</xsl:attribute> <xsl:attribute name='onClick'> window.open("./?cmmd=insertform&plan_id=" + parent.document.select_form.id.value, "_self"); </xsl:attribute> </xsl:element> ...