『第
2 楼』:
多看看基础的东西吧,其实方法真的太多了...
<script language="VBScript">
Sub queding
set colRadios = document.getElementsByName("R1")
if colRadios(0).checked then
alert "男"
else
alert "女"
end if
End Sub
</script>
性别:<input type="radio" value="V1" checked name="R1">男
<input type="radio" value="V2" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON>
<script language="VBScript">
Sub queding
set colRadios = document.all.R1
if colRadios(0).checked then
alert "男"
else
alert "女"
end if
End Sub
</script>
性别:<input type="radio" value="V1" checked name="R1">男
<input type="radio" value="V2" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON>
<script language="VBScript">
Sub queding
set colRadios = document.getElementsByName("R1")
if colRadios(0).checked then
alert "男"
else
alert "女"
end if
End Sub
</script>
性别:<input type="radio" value="男" checked name="R1">男
<input type="radio" value="女" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON>
<script language="VBScript">
sValue = "男"
Sub queding
alert sValue
End Sub
</script>
性别:<input type="radio" OnClick="sValue='男'" language="vbscript" checked name="R1">男
<input type="radio" OnClick="sValue='女'" language="vbscript" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON>
<script language="VBScript">
Sub queding
on error resume next
for each itemElement in document.ALL
if lcase(itemElement.tagName) = "input" then
if lcase(itemElement.type) = "radio" then
if itemElement.checked then
alert "男"
exit for
else
alert "女"
exit for
end if
end if
end if
next
End Sub
</script>
性别:<input type="radio" value="V1" checked name="R1">男
<input type="radio" value="V2" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON>
<script language="VBScript">
Sub queding
set colRadios = document.getElementsByTagName("input")
if colRadios(0).checked then
alert "男"
else
alert "女"
end if
End Sub
</script>
性别:<input type="radio" value="V1" checked name="R1">男
<input type="radio" value="V2" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON>
<script language="VBScript">
Sub queding
' if v1.checked then
if document.getElementbyId("V1").checked then
alert "男"
else
alert "女"
end if
End Sub
</script>
性别:<input type="radio" id="V1" checked name="R1">男
<input type="radio" id="V2" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON>
<script language="VBScript">
Sub queding
if document.body.children(0).checked then
alert "男"
else
alert "女"
end if
End Sub
</script>
性别:<input type="radio" value="V1" checked name="R1">男
<input type="radio" value="V2" name="R1">女<p>
<BUTTON onClick="queding">确定</BUTTON> 此处省略方案若干种...
既然有Microsoft这个后盾,何不更人性化一点呢?
<body onKeyDown="fastkey(window.event.keyCode)" language='vbscript'>
<script language="VBScript">
Sub fastkey(key)
select case key
case 13
queding
case 27
set self.opener = Nothing
self.close
end select
end sub
Sub queding
for each itemElement in document.getElementsByName("R1")
if itemElement.checked then alert itemElement.value
next
End Sub
</script>
性别:<input type="radio" value="男" checked name="R1" id="o1">
<label for="o1" accessKey="1">男(ALT+<u>1</u>)</label>
<input type="radio" value="女" name="R1" id="o2">
<label for="o2" accessKey="2">女(ALT+<u>2</u>)</label><p>
<BUTTON id="oButton" onClick="queding">确定</BUTTON>
</body>
|