注册 登录
编程论坛 ASP技术论坛

HTML里button的名字是变量,vbscript里该怎么表示

Kettyjin1983 发布于 2008-02-21 10:30, 2672 次点击
HTML里button的名字是变量,vbscript里该怎么表示
<select name=<% =manage %> size="1">
    <option value="wait">****select</option>
    <option value="accept">accept</option>
    <option value="reject">reject</option>
</select>
<script language="VBScript">
function action_OnClick()
    if Form1.manage.option.value = "accept" then---这个地方该怎么写啊??
    MsgBox "You have accepted this barcode!"
    elseif Form1.manage.option.value = "reject"  then
    MsgBox "You have rejected this barcode!"
    end if
    Form1.submit
    
end function
</script>
10 回复
#2
dhdhzzw2008-02-21 11:23
dim manage
manage= <%=manage %>
#3
Kettyjin19832008-02-21 13:07
不是,是在vbscript里面怎么表示,不行.
#4
smlx98072008-02-21 14:02
请可以使用javascript 来实现!用ID属性进行引用。
#5
Kettyjin19832008-02-21 14:46
能否回答的具体点啊,不太懂Javascript...
#6
multiple19022008-02-21 14:51
<input name="<%=manage%>" ..... />

<script language="vbscript">
document.<%=manage%>.value="test"
</script>
#7
Kettyjin19832008-02-21 15:51
还是不行,贴出原代码,再帮我看看是哪错了...
<script language="VBScript">
function action_OnClick()
    select case document.form1.<% =manage %>.option.value
        case "wait"
        MsgBox "This barcode is still wait your response!"
        case "accept"
        MsgBox "You accept this barcode!"
        case "reject"
        MsgBox "You reject this barcode!"
    end select
    form1.submit
end function
</script>
------
<td><select name=<% =manage %> size="1">
            <option value="wait">****select</option>
            <option value="accept">accept</option>
            <option value="reject">reject</option>
            </select>
            
            </td>
<input type="button" name="action" value="take action">
#8
yms1232008-02-21 16:12
VBScript的写法
<script language="VBScript">
Dim manage
function action_OnClick()
     manage=document.all("<% =manage %>")
     manageValue=manage.options(manage.selectedIndex).value
     select case manageValue
        case "wait"
        MsgBox "This barcode is still wait your response!"
        case "accept"
        MsgBox "You accept this barcode!"
        case "reject"
        MsgBox "You reject this barcode!"
    end select
    form1.submit
end function
</script>
javascript的写法
<script language="javascript">
var manage;
function action_OnClick()
{
     manage=document.form1.<% =manage %>;
     manageValue=manage.options[manage.selectedIndex].value;
     switch(manageValue)
     {
        case "wait":
             alert("This barcode is still wait your response!");
        break;
        case "accept":
             alert("You accept this barcode!");
        break;
        case "reject":
             alert("You reject this barcode!");
        break;
    }
    document.form1.submit();
}
</script>

[[it] 本帖最后由 yms123 于 2008-2-21 16:15 编辑 [/it]]
#9
Kettyjin19832008-02-22 15:29
manage.options(manage.selectedIndex).value中的selectedIndex是什么意思,与manage.options.value有什么区别啊?
#10
tianyu1232008-02-22 16:04
manage.options(manage.selectedIndex).value
selectedIndex
表示当前选项的索引值,索引值从0开始,依次递增。就像数组的索引值。
#11
yms1232008-02-22 19:38
manage.options是下拉列表的选项数组,这里面有很多option选项。
而manage.options.value这个错误的原因是,楼主直接操作整个数组。这个数组有N多的value,程序运行到这里计算机是无法知道要取得那个元素的value值,所以出错误。
而selectedIndex属性是取得下拉列表当前选中项的索引值(也就是第几个选项),用这个做为选项数组下标确定了第几个选项后,就能取得value值了。
1