| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1167 人关注过本帖
标题:为什么单选按钮 document。getelementbyid()取值会有问题红色部分
取消只看楼主 加入收藏
a124211741
Rank: 2
等 级:论坛游民
帖 子:29
专家分:35
注 册:2011-3-21
结帖率:100%
收藏
 问题点数:0 回复次数:3 
为什么单选按钮 document。getelementbyid()取值会有问题红色部分
程序代码:
<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> 
搜索更多相关主题的帖子: document color 
2011-03-24 11:53
a124211741
Rank: 2
等 级:论坛游民
帖 子:29
专家分:35
注 册:2011-3-21
收藏
得分:0 
问题补充:
   
程序代码:
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
在这段代码的中间那段elseif 这段没有被执行 ,为什么?求解,求高人指点
2011-03-24 11:54
a124211741
Rank: 2
等 级:论坛游民
帖 子:29
专家分:35
注 册:2011-3-21
收藏
得分:0 
程序代码:
if document.getElementById("option").value =1 and document.getElementById("option").checked = true then
    y=1
elseif document.getElementById("option").value =2 and document.getElementById("option").checked = true then
    y=2
else
    y=3
end if
但是就算改成这样的结果elseif语句还是完全没有被执行啊
2011-03-24 17:15
a124211741
Rank: 2
等 级:论坛游民
帖 子:29
专家分:35
注 册:2011-3-21
收藏
得分:0 
我将option.value = 2  的控件 单机,也就是说符合条件elseif了 ,可是运行的时候只有 value 1 和 3 被执行 ,就算我选到了value = 2 的单选按钮 他也是直接执行 else 语句,完全忽略了elseif语句
2011-03-24 17:24
快速回复:为什么单选按钮 document。getelementbyid()取值会有问题红色部分
数据加载中...
 
   



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

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