« 遥かなる時空の中で 〓八葉抄〓(こうさぎ) [via cocousagi](BlogPet) | トップページ | モンドールAOC、再び »
2005.11.21
簡単そうで難しい問題
問題
以下のような「プルダウン形式」のセレクトボックス 2つからなる html ファイルがあるとします。
<html> <head> <title>ComboBox Test</title> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script type="text/javascript"> function openSelect() { f.select1.selectedIndex = 0; f.select1.focus(); } function selectItem() { f.select2.options[1] = new Option(f.select1.options[f.select1.selectedIndex].value + 0); f.select2.options[2] = new Option(f.select1.options[f.select1.selectedIndex].value + 1); f.select2.options[3] = new Option(f.select1.options[f.select1.selectedIndex].value + 2); f.select2.options[f.select.selectedIndex].setAttribute("selected","selected"); } function selectItem2() { f.select2.focus(); } </script> </head> <body onload="openSelect();"> <form name="f"> <select name="select1" id="select1" onchange="selectItem()" style="width: 150px;"> <option value=""></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <br> <select name="select2" id="select2" onchange="selectItem2()" style="width: 150px;"> </select> </form> </body> </html>
このファイルを Internet Explorer, Firefox, Opera 等のブラウザで開き、以下のような操作をします。
ブラウザで開いた直後
(1) 上のセレクトボックスを開き
(2) 例えば 2 を選択します
すると、以下のような表示になります。
ここで、問題です。2 を選択したときに、上記のような表示ではなく、下のような表示(下の方のセレクトボックスが開いた状態)になるようにするには、冒頭の html ファイルをどのように書き換えればいいでしょうか?
この絵のような状態にしたい
この問題、簡単そうに見えて、結構むずかしいです。おそらく、回答は1通りではないと思いますが、わかった人は答えを書いて、トラックバックもしくはメール等でお知らせください。
投稿者: tsupo 2005.11.21 午後 11:26
| 固定リンク
|
|
|
|
|
|
|
|
|
|
|
|
「プログラミング」カテゴリ内の最近の記事
2010-03-11 Twitter API 解説本に載せるサンプルコードを募集します
2009-12-28 冬コミ(C77)でTwitter本、頒布します
2009-12-19 tumblr の「Twitter互換API」を試しに使ってみました
2009-12-03 Twitter API の変遷 (仮) - 「第1回Twitter研究会」発表用資料
「日記・コラム・つぶやき」カテゴリ内の最近の記事
2009-06-23 Google Wave に潜入してみた
2009-06-16 Windows XP → Vista 移行ではまる罠
2009-03-13 メモ: NHK BS で Twitter 関連番組?
2008-12-31 シャンプーと個人情報
2008-11-30 【イベント参加レポート】 はてなブックマークPR大作戦
アマゾンわくわく探検隊
トラックバック
この記事のトラックバックURL:
http://app.cocolog-nifty.com/t/trackback/6737/7254555
この記事へのトラックバック一覧です: 簡単そうで難しい問題: