这个函数怎么写?-----在线急等

YuriOU 2003-10-20 03:25:33
有一个列表框,当点击一个按钮时,上一个option选中.

比如:当前时option[3]选中状态.当点击按钮时.是option[2]处于选中状态.
...全文
34 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
longshenwang 2003-10-20
  • 打赏
  • 举报
回复
UP//..........
kingdomzhf 2003-10-20
  • 打赏
  • 举报
回复
<body>
<script>
function previous()
{
var s1 = document.all("s1");
if(s1.selectedIndex >= 1 )
{
s1.selectedIndex = s1.selectedIndex - 1;
}
}
function next()
{
var s1 = document.all("s1");
if(s1.selectedIndex < s1.options.length - 1 )
{
s1.selectedIndex = s1.selectedIndex + 1;
}
}
</script>
<select id=s1>
<option>
a
</option>
<option>
b
</option>
<option>
c
</option>
<input type=button value="previous" onclick="previous();">
<input type=button value="nex" onclick="next();">
</select>
</body>
hrh1979 2003-10-20
  • 打赏
  • 举报
回复
select1.selectIndex=2
孟子E章 2003-10-20
  • 打赏
  • 举报
回复
<form name=form1 action="1.asp">
<input name=a type=button onclick="aa()">
<select name="S" id="select1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3" selected>3</option>
</select>
<input type=submit>
</form>
<script>
function aa()
{
document.form1.elements["S"].options[1].selected=true

}
</script>

梦想成真2003 2003-10-20
  • 打赏
  • 举报
回复
if (window.form1.select1.selectedindex>=-1){
window.form1.select1.selectedIndex=window.form1.select1.selectedIndex-1}

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧