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

求解。。红色那段代码中的elseif语句不执行得到的y值只有1和3为什么

a124211741 发布于 2011-03-23 16:59, 427 次点击

<input name="option" type="radio" value="1" checked="checked"/>
<input type="radio" name="option" value="2" />
<input type="radio" name="option" value="3" />
<input name="option1" type="radio" value="1" />        
<input type="radio" name="option2" value="2" />
<input type="radio" name="option3" value="3" />
<script language="vbscript">
function pk()
document.getElementById("option1").checked = false
document.getElementById("option2").checked = false
document.getElementById("option3").checked = false
dim x,y,a,w
randomize
x = int(rnd()*3)+1
select case x
case 1
document.getElementById("option1").checked = true
case 2
document.getElementById("option2").checked = true
case 3
document.getElementById("option3").checked = true
end select
if document.getElementById("option").value =1 and document.getElementById("option").checked = true then
    y=1
elseif document.getElementById("option").value =1 and document.getElementById("option").checked = true then
    y=2
else
    y=3
end if

if  x - y = -1 or  x - y = 2  then
msgbox "恭喜你,你赢了 "
elseif x - y = 0 then
msgbox "打平手"
else
msgbox "电脑胜出"
end if
end function
</script>
1 回复
#2
a1242117412011-03-23 17:02
上面的代码有一个数字错误,在这里修改下elseif document.getElementById("option").value =2 and document.getElementById("option").checked = true then

该语句没有被执行,我不知道为什么。求强人解答。
1