出来るのだASP Q&A掲示板(過去LOG)
訪問数 52046
昨日 889
今日 776 【PR】 パソコン入門からIT専門書まで幅広く取り揃えています。セブン-イレブン受取り手数料無料のセブンアンドワイ。 |
![]() ![]() ![]() ![]() ![]() |
[5251] Re:テキストBOXの値の受け渡しについて |
投稿者:暇人さん 2005/09/07 16:01:13 |
ryuさんのつっこみに補足します。 第一チェックポイント > <td><input type="button" value="検索実行" onClick=MakeChild(this) target="_blank" id=button1 name=button1></td> 1、HTMLの属性の値は"か'で囲むようにしましょう。 特にscriptの所は絶対に囲むようにしましょう。 空白とか入ることありますし、,とかも誤作動するし文字型定数値を入れようとして'a'とかを関数の引数に入れたらまた誤作動します。 つまり onClick=MakeChild(this) これは絶対駄目です。 onClick=MakeChild('a')とかやったらもうアウトですから。 ASPは動的にHTMLを吐き出すのが特徴です。 onClick="MakeChild('<%=strA%>')" とかよくやるので、動くからいいじゃん?なんていってると後で泣きをみます。 2、誤作動の原因になるから使わない(使えない)属性は使わないようにしましょう。 target="_blank" これはInputタグの属性にないですね。やめましょう。 第二チェックポイント > <<javaスクリプト>> > function MakeChild() > { > window.document.hoge.method = "POST"; > window.document.hoge.action = "child.asp"; > window.document.hoge.submit(); > window.open("child.asp","_blank","scrollbars=1"); > } ryuさんがつっこんでくれた所は省略します。 1、submitとopenの順番が逆です。openした先にsubmitするわけです。 2、以下例 function test(){ f = document.[フォーム名]; f.method = "post"; f.action = "child.asp"; //↓ウィンドウの名前は適当なものに変えて下さい window.open("about:blank","testdesu"); //↑初期値は空白にしてあります。 f.target = "testdesu"; f.submit(); } > 質問させて下さい。今、このような形でテストしています。 > > <<start.asp>> > <table> > <tr> > <form name = "hoge" method="post"> > <td>コード検索</td> > <td><input type="text" name="hid"></td> > <td><input type="button" value="検索実行" onClick=MakeChild(this) target="_blank" id=button1 name=button1></td> > </tr> > <tr> > <td>場所検索</td> > <td><input type="text" name="hbasyo"></td> > <td><input type="button" value="検索実行" onClick=MakeChild(this) target="_blank" id=button2 name=button2></td> > </form> > </tr> > </table> > > <<javaスクリプト>> > function MakeChild() > { > window.document.hoge.method = "POST"; > window.document.hoge.action = "child.asp"; > window.document.hoge.submit(); > window.open("child.asp","_blank","scrollbars=1"); > } > > この状態でどちらの検索実行を実行しても値が渡せません。 > また検索実行後、start.asp自体もchild.aspに変わってしまいます。 > MakeChild()がいけないような気がしますが…。分かりません。 > > また、このhid、hbasyo以外の値を一緒に渡したい場合は > どうしたら良いですか? > MakeChild()をMakeChild(strA,strB)のように引数を加えて > "child.asp?aaa=" + strA + "&bbb=" + strBとすればいい > と思いましたが、 > onClick=MakeChild(this)をどう記述することになるのでしょうか? > onClick=MakeChild(this,"<%=strAAA%>","<%=strBBB%>")で良いのですか?? > > 未熟ですみません、アドバイスお願いします。 > |
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
TreeBBS For ASP V.0.1.3 |