[問題] 多個下拉選單並存

看板Ajax作者 (陌生)時間17年前 (2008/05/10 07:11), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/2 (看更多)
想請教如何在一個頁面當中出現多個下拉式選單? 我目前是這樣寫:(沒有用到資料庫,只有連到該網頁) <form id="form1" name="form1" method="post" action=""> <script language="JavaScript"> <!-- function surfto(form) {var myindex=form.select1.selectedIndex; window.open(form.select1.options[myindex].value,'_self','');} //--> function showInfo(obj) {alert(obj[obj.selectedIndex].getAttribute("text"));} </script> <select name="select1" id="form" onchange="document.getElementById('ft1'). innerHTML=''+this[this.selectedIndex].title;"> <option value="000.html" title="000" selected="selected">000</option> <option value="111.html" title="111">111</option> <option value="222.html" title="222">222</option> </select> <input type="button" value="GO" onClick="surfto(this.form)"/></form> <span id="ft1"></span> 可是只要複製第二個,就會打架,其中一個無法使用, 就算改變select1為select2也沒有辦法, 想請問還有哪邊需要改? 還有一個問題是,我要讓他選擇後(還沒按GO)先顯示title的值, 這部份是已經ok的,但一進入網頁時,他並不會先出現預設(000)的title, 必須先選到111、222...才會出現, 不知道該怎麼修改,讓他直接先出現selected的title? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.165.163.104 ※ 編輯: gpgpt 來自: 118.165.163.104 (05/10 07:12)

05/10 11:49, , 1F
你的問題跟你預期的結果描述的不夠清楚.
05/10 11:49, 1F

05/10 15:21, , 2F
是不是 id="form" 的問題?
05/10 15:21, 2F

05/11 21:41, , 3F
嗚~可能我不太懂JS,只能硬套,也不知道比較專業的說法>"<
05/11 21:41, 3F
文章代碼(AID): #189DeJkP (Ajax)
文章代碼(AID): #189DeJkP (Ajax)