社区
JavaScript
帖子详情
如何得到select里选中的选项的selectedIndex的值?
andy0618
2005-10-31 10:09:07
如何得到select里选中的选项的selectedIndex的值?
...全文
602
8
打赏
收藏
如何得到select里选中的选项的selectedIndex的值?
如何得到select里选中的选项的selectedIndex的值?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
lzj34
2006-01-18
打赏
举报
回复
问题是如果没有选择呢!结果还能运行正常吗
andy0618
2005-10-31
打赏
举报
回复
问题解决,和 TaoTaoYou(超级大菜鸟,每天要学习!) 你说的基本相同,但不知这是不是最好的方法
TaoTaoYou
2005-10-31
打赏
举报
回复
重点:
1 <input type=text name=ppname class=wenbenkuang>‘名字为ppname的文本框控件
2 > <select name=spname onChange='(document.addSP.ppname.value=this.options[this.selectedIndex].value)'>"
response.write"<option selected>请选择品牌</option>"
while not rs.eof
response.write"<option value="&rs("spname")&">"&rs("spname")&"</option>"
</select> 注意onChange重点在这里,这句的意思是ppname的value等于你选的这个值
TaoTaoYou
2005-10-31
打赏
举报
回复
用实例给你说明一下吧,恰巧我刚用到这个东西,,,还热着呢
response.write"<center>"
response.write"<form name=addSP action='' method='post'>"
response.write"<table border=0><tr><td>商品品牌:</td>"
response.write"<td><input type=text name=ppname class=wenbenkuang></td>"
Set rs=Server.Createobject("adodb.recordset")
sql="select * from pinpan where sporder>0 order by sporder"
rs.open sql,conn,1,1
response.write"<td><select name=spname onChange='(document.addSP.ppname.value=this.options[this.selectedIndex].value)'>"
response.write"<option selected>请选择品牌</option>"
while not rs.eof
response.write"<option value="&rs("spname")&">"&rs("spname")&"</option>"
rs.movenext
wend
rs.close
response.write"</td></tr>"
梅雪香
2005-10-31
打赏
举报
回复
<select id="dlt">
<option value=0>0</option>
<option value=1 selected>1</option>
<option value=2>2</option>
</select>
<script language="JavaScript">
<!--
alert(dlt.selectedIndex);
//-->
</script>
starytx
2005-10-31
打赏
举报
回复
关注!
andy0618
2005-10-31
打赏
举报
回复
能说的详细点吗
梅雪香
2005-10-31
打赏
举报
回复
selectid.selectedIndex;
JQuery设置获取下拉菜单某个
选项
的
值
(比较全)
获取
select
选中
的 value: $(“#ddlRegType “).val(); 获取
select
选中
的索引: $(“#ddlRegType “).get(0).
select
ed
Index
; 设置
select
: 设置
select
选中
的索引: $(“#ddlRegType “).get(0).
select
ed
Index
=
index
;//...
JQuery 获取和设置
Select
选项
的代码
获取
select
选中
的索引: $(“#ddlRegType “).get(0).
select
ed
Index
; 设置
select
: 设置
select
选中
的索引: $(“#ddlRegType “).get(0).
select
ed
Index
=
index
;//
index
为索引
值
设置
select
选中
的value: $(“#...
js
select
类
//
得到
select
项的个数 jQuery.fn.size = function(){ return $(this).get(0).options.length; } //获得
选中
项的索引 jQuery.fn.get
Select
ed
Index
= function(){ return $(this).get(0).
select
ed
Index
; ...
浅析JQuery获取和设置
Select
选项
的常用方法总结
1.获取
select
选中
的 text: $(“#...3.获取
select
选中
的索引: $(“#ddlRegType “).get(0).
select
ed
Index
;4.
得到
select
项的个数 $(“#cusChildTypeId”).get(0).options.length5.设置
select
选中
的索引:
浅析Jquery操作
select
话不多说,请看代码: <
select
id=
Select
1> 一 二 三 四 </
select
>...这时已经
选中
了 value是two的
选项
,通过$(“#
Select
1”)[0].
select
ed
Index
或者$(“#
Select
1”).get(0).
select
ed
In
JavaScript
87,922
社区成员
224,618
社区内容
发帖
与我相关
我的任务
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
分享
社区描述
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章