プロが教える店舗&オフィスのセキュリティ対策術

質問です。

1つのformで複数のactionを1つの送信ボタンで実行したいと思っています。
やりたいことは、1つのframeから他の2つのframeにデータを渡すことです。

フレームは以下のように3つに分かれています。
<frameset cols="60%, 40%">
<frame name="test1" src="xxxx.php">
<frameset rows="50%, 50%">
<frame name="test2" src="yyyy.php">
<frame name="test3" src="zzzz.php">
</frameset>
</frameset>

xxxx.php内のデータをyyyy.php, zzzzphpの2つに渡したいです。

<script language="javascript">
function send(){
  document.form1.target = "test2";
  document.form1.action = "yyyy.php";
  document.form1.submit();
  document.form1.target = "test3";
  document.form1.action = "zzzz.php";
  document.form1.submit();
}
</script>

<form name ="form1" method="POST" action="yyyy.php">
<input type="hidden" name="string" value="string" >
<input type="button" value="送信" onClick="send()">
</form>


現在、上記のように試したり、過去の質問【一つのformから複数のactionを実行】url:http://okwave.jp/qa/q4234502.htmlを参考にしていますがうまくいきません。

わかる方アドバイスお願い致します。

A 回答 (1件)

nameでの参照が悪いのかもしれません


オブジェクトを直接わたしてみては?

<script>
function send(f){
f.target = "test2";
f.action = "yyyy.php";
f.submit();
f.target = "test3";
f.action = "zzzz.php";
f.submit();
}
</script>

<form method="POST">
<input type="hidden" name="string" value="string" >
<input type="button" value="送信" onClick="send(this.form)">
</form>
    • good
    • 1
この回答へのお礼

うまくできました!!
本当に感謝です。
ありがとうございました。

お礼日時:2011/11/21 02:51

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!