获取select的text值

网客Q 2007-07-18 09:23:46
<select name="abc" id="abc">
<option value="99">abc</option>
</select>

提交后怎么样才能获取“abc”,而不是VALUE的值99
...全文
730 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
ASP_sem 2007-07-18
  • 打赏
  • 举报
回复
我也在为这个问题苦恼


var abc = document.getElementById("abc");
alert(abc.options[abc.selectedIndex].text);

要写在哪呢,要不要加<script>之类的东西呢,还是直接写到
<select name="abc" id="abc">
<option value="99">abc</option>
</select>
select之间呢
huo789 2007-07-18
  • 打赏
  • 举报
回复
var abc = document.getElementById("abc");
alert(abc.options[abc.selectedIndex].text);
wasuka 2007-07-18
  • 打赏
  • 举报
回复
不能。除非借助javascript
waitxing 2007-07-18
  • 打赏
  • 举报
回复
把99改成abc...
网客Q 2007-07-18
  • 打赏
  • 举报
回复
要ASP的
XJY123 2007-07-18
  • 打赏
  • 举报
回复
if a="abc" then
x=99
end if
什么都不能 2007-07-18
  • 打赏
  • 举报
回复
<option value="abc">abc</option>
XJY123 2007-07-18
  • 打赏
  • 举报
回复
把value="99"去掉,然后取到值后在做判断
如:
if a='abc' then
x=99
end if
罗罗的洋洋 2007-07-18
  • 打赏
  • 举报
回复
如果是服务器端脚本的话,只能获得提交的被选中的option的value中的值,那个abc是没法获得的,客户端脚本要获得其值的话,那么就可以通过huo789的方法获得
无名__ 2007-07-18
  • 打赏
  • 举报
回复
huo789(爱拼才会赢) 正解
ASP_sem 2007-07-18
  • 打赏
  • 举报
回复
<html>
<head>
<title>获取下拉列表文本</title>
<script language="javascript">
function abc_Change()
{
alert(this.abc.options[this.abc.selectedIndex].text);
}
</script>
</head>
<body>
<select name="abc" id="abc" onChange="abc_Change();">
<option value="99">abc</option>
</select>
<input type="button" name="Clk" value="获取选择文本" onClick="abc_Change();" >
</body>
</html>

28,391

社区成员

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

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