( IEはversion 6.0で確認、Firefoxは version 2.0で確認しました)
○ サンプルですがHTMLは以下のようになっております。
<form action="AAA.cgi">
<input type="text" name="firstname" />
<div id="xyz"><input type="text" name="lastname" /></div>
</form>
○ これもサンプルですが、javascriptは以下のようになっております。
// id に 'xyz' を持つタグの高さを 200 に設定
if (document.all) {
document.all("xyz").setAttribute("height",200);
}else{
document.getElementById("xyz").setAttribute("height",200);
}
ちなみに、div タグを form の外に出すと動作しますが、今回は form の中に存在するのが必須条件となります。
以上、宜しくお願い致します。
IE の setAttribute は目的どおりの動作はしてくれないので、style.cssText で対処してみてください。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html lang="ja"> <head> <meta http-equiv="content-type" content="text/html; charset=shift_jis"> <meta http-equiv="content-style-type" content="text/css"> <meta http-equiv="content-script-Type" content="text/javascript"> <title>タイトル</title> </head> <body> <form action="AAA.cgi"> <input type="text" name="firstname" /> <div id="xyz" style="border-style:double; height:100px"> <input type="text" name="lastname" /> </div> </form> <script> if (document.all) { document.all("xyz").style.cssText = "border-style:solid; height:200px"; }else{ document.getElementById("xyz").setAttribute("style","border-style:solid; height:200px"); } </script> </body> </html>
if (document.all) {
document.all("xyz").style.height = 200;
}else{
document.getElementById("xyz").style.height = 200;
}
でどうですか?
質問内容に重大な抜けがありまして・・・。
は動的に生成されるんです。なので、質問は FORM内の動的に生成されるタグ(id付き)のheightを変更したいのです。 こちらの方、解りますでしょうか?
JavaScript の部分を下記の1行に替えれば良いのではないでしょうか?
document.getElementById("xyz").style.height = "200px";
(setAttribute を使うなら ~("style", "height:200px;"); かなと思います)
質問内容に重大な抜けがありまして・・・。
は動的に生成されるんです。なので、質問は FORM内の動的に生成されるタグ(id付き)のheightを変更したいのです。 こちらの方、解りますでしょうか?
質問内容に重大な抜けがありまして・・・。
は動的に生成されるんです。なので、質問は FORM内の動的に生成されるタグ(id付き)のheightを変更したいのです。 こちらの方、解りますでしょうか?