关于下拉框(select)的问题

rainxue 2001-12-13 09:58:22
为什么下拉框(select)加了disabled属性后,就取不到它的value了
除了disabled,还有没有其他的方式可以让下拉框的值不受改变
...全文
84 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tonnycncn 2001-12-15
  • 打赏
  • 举报
回复
下拉框的值不受改变?
不用下拉框,用文本框不就行了,
BrightEye 2001-12-14
  • 打赏
  • 举报
回复
加DISABLED?好象禁止了这个下拉框了哦(变灰了,好象)!当然取不倒值了。
rainxue 2001-12-14
  • 打赏
  • 举报
回复
这个问题这么难吗
karma 2001-12-14
  • 打赏
  • 举报
回复
what are you using? ASP? then based on the 权限, you can always change it, for example,


<script>
var selectedIndex;
function init()
{
selectedIndex = document.frm.sel.selectedIndex;
}
function changeSelection()
{
<%if this guy does not 特殊权限%>
document.frm.sel.selectedIndex=selectedIndex;
<%end if%>
}
</script>
<body onload="init();">
<form method="post" name="frm">
<select name="sel" id="sel" onchange="changeSelection();">
<option value="1">1</option>
<option value="2" selected>2</option>
</select>
</form>
rainxue 2001-12-14
  • 打赏
  • 举报
回复
我现在面临的问题是,当不同的人进入该页面时,下拉框默认为不同的值,并且不能改变;当特殊权限的人进入时,可以选择改变select框的值。而且又要在该文件的action文件里取得这个select的值。若按你的方法我也要控制当特殊权限的人进入时不让他触发onchange事件,那我倒不如:
<select name="sel" disabled>
<option value="1">1</option>
<option value="2" selected>2</option>
</select>

<input type=hidden name=sel value=2>

但我总觉得这两种都不是最好的方法,不知其他朋友有何高见

karma 2001-12-14
  • 打赏
  • 举报
回复
I do not think you can cancel the change of selection in onchange event handler, but you can remember the current selection, when the user makes a different selection, you change it back, for example:

<script>
var selectedIndex;
function init()
{
selectedIndex = document.frm.sel.selectedIndex;
}
function changeSelection()
{
document.frm.sel.selectedIndex=selectedIndex;
}
</script>
<body onload="init();">
<form method="post" name="frm">
<select name="sel" id="sel" onchange="changeSelection();">
<option value="1">1</option>
<option value="2" selected>2</option>
</select>
</form>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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