作者gpgpt (陌生)
看板Ajax
标题[问题] 多个下拉选单并存
时间Sat May 10 07:11:14 2008
想请教如何在一个页面当中出现多个下拉式选单?
我目前是这样写:(没有用到资料库,只有连到该网页)
<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)
1F:→ TonyQ:你的问题跟你预期的结果描述的不够清楚. 05/10 11:49
2F:推 itisjoe:是不是 id="form" 的问题? 05/10 15:21
3F:→ gpgpt:呜~可能我不太懂JS,只能硬套,也不知道比较专业的说法>"< 05/11 21:41