
Object doesn't support this property or method
Quote:
> I'm creating an HTA form that has an array of three option buttons. I
> want to retrieve the value of the selected option button but cannot.
> I've tried using name.value, name.checked(or selected),
> name.checked(or selected).value, name.tabindex.value,
> name.tabindex().checked, etc. and nothing seems to work.
> Which one am I missing to make this work? I can reference a drop
> down list no problem through its name.value property, but I'd rather
> use the option buttons.
Radio buttons with the same name form a collection (HTMLElementCollection to
be precise). It can be enumerated with For Each x In y syntax and can also
be indexed using it's 1-based .Count property and 0-based .Item(index)
property.
<html>
<head>
<script language='VBScript'>
sub GetOption()
set opts = myform.myOpt
set selOpt = nothing
for each opt in opts
if opt.checked then
set selOpt = opt : exit for
end if
next
if selOpt is nothing then
msgbox "no option selected"
exit sub
end if
msgbox "you selected option value=" & selOpt.value
end sub
</script>
<body>
<form name=myform>
<input type=radio name=myOpt value="a"> Option A<br>
<input type=radio name=myOpt value="b"> Option B<br>
<input type=radio name=myOpt value="c"> Option C<br>
<input type=button name=myBtn value="Get Option"
onclick='GetOption'>
</body>
</html>
--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US