一个比较弱智的问题

zz95469 2006-06-15 12:01:34
在vbs 中怎么才能引用select
中某一项被选中的项的值

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<SELECT ID="oSelect" NAME="Cars" size="5" >
<OPTION VALUE="宝马" SELECTED>宝马</OPTION>
<OPTION VALUE="保时捷">保时捷</OPTION>
<OPTION VALUE="奔驰">奔驰</OPTION>
</SELECT>
<input name="but3" type="button">
<script language="VBScript">
sub but3_onclick
set oOption = document.createElement("OPTION")
oSelect.options.add(oOption)
oOption.innerText = "Two"
oOption.value = "2"
end sub


sub oSelect_onchange
dim mystr
mystr=oselect.optios[oselect.selectedIndex].value
window.alert mystr
end sub


</script>

</body>
</html>

出错在哪里啊
...全文
260 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
llbd 2006-06-17
  • 打赏
  • 举报
回复
我也不是太会,同上!!!
AppleBBS 2006-06-16
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<SELECT ID="oSelect" NAME="Cars" size="5" >
<OPTION VALUE="宝马" SELECTED>宝马</OPTION>
<OPTION VALUE="保时捷">保时捷</OPTION>
<OPTION VALUE="奔驰">奔驰</OPTION>
</SELECT>
<input name="but3" type="button">
<script language="VBScript">
sub but3_onclick
set oOption = document.createElement("OPTION")
oSelect.options.add(oOption)
oOption.innerText = "Two"
oOption.value = "2"
end sub


sub oSelect_onchange
dim mystr
mystr=oselect.options(oselect.selectedIndex).value
window.alert mystr
end sub


</script>

</body>
</html>
是是非非 2006-06-15
  • 打赏
  • 举报
回复
mystr=oselect.optios[oselect.selectedIndex].value

==>

mystr=oselect.options(oselect.selectedIndex).value


1、optios 改成 options 拼写错误
2、VBS里面取数组是用()不是[]

4,008

社区成员

发帖
与我相关
我的任务
社区描述
它是一种微软环境下的轻量级的解释型语言,它使用COM组件、WMI、WSH、ADSI访问系统中的元素,对系统进行管理。
社区管理员
  • vbScript社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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