| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 410 人关注过本帖
标题:求解。。红色那段代码中的elseif语句不执行得到的y值只有1和3为什么
只看楼主 加入收藏
a124211741
Rank: 2
等 级:论坛游民
帖 子:29
专家分:35
注 册:2011-3-21
结帖率:100%
收藏
 问题点数:0 回复次数:1 
求解。。红色那段代码中的elseif语句不执行得到的y值只有1和3为什么

<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>
搜索更多相关主题的帖子: function checked option 
2011-03-23 16:59
a124211741
Rank: 2
等 级:论坛游民
帖 子:29
专家分:35
注 册:2011-3-21
收藏
得分:0 
上面的代码有一个数字错误,在这里修改下elseif document.getElementById("option").value =2 and document.getElementById("option").checked = true then

该语句没有被执行,我不知道为什么。求强人解答。
2011-03-23 17:02
快速回复:求解。。红色那段代码中的elseif语句不执行得到的y值只有1和3为什么
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014374 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved