Discussion:
(newbie) how to access radio button in vbs?
(too old to reply)
Rachel Phillips
2019-08-20 21:41:09 UTC
Permalink
how is this done in script for cscript.exe?
I don't know if your problem is related to array of HTML elements or not.
Try this code and look if it can help you or it can suggest anything useful.
<HTML>
<TITLE>How To manage Array of HTML Elements HTML in VBScript.</TITLE>
<HEAD></HEAD>
<BODY>
<SCRIPT LANGUAGE="VBScript">
Sub cmdStart_OnClick()
For x = 0 To 9
If Document.frmID.Elements(x).Value = "" Then
Document.frmID.Elements(x).Value = "txtTextBox" & x + 1
End If
Next
MsgBox "I listed all textboxes as an array of elements. Now i will proceed
with the verify of the txtTextBox5 existence then i will set its value to
'0'."
For x = 0 To 9
If Document.frmID.Elements(x).Value = "txtTextBox5" Then
MsgBox "The fifth textbox contains the name: txtTextBox5. When you will
press 'OK' , its value will be '0'."
Document.frmID.Elements(x).Value = "0"
End If
Next
End Sub
Sub cmdStart2_OnClick()
For y = 0 TO 4
If Document.frmID2.Elements(y).Value = "" Then
Document.frmID2.Elements(y).Value = "txtTextBox" & y + 1
End If
Next
End Sub
</SCRIPT>
<FORM Name="frmTry" Id="frmID">
<%
For x = 1 To 10
%>
<INPUT Type="Text" Name="txtTextBox<%= x%>">
<%
Next
<INPUT Type="Button" Name="cmdStart" Value="Start">
</FORM>
<FORM Name="frmStart2" Id="frmID2">
<%
For y = 1 To 5
<CENTER>
<INPUT Type="Text" Name="txtTextBox<%= y%>">
</CENTER>
<%
Next
%>
<CENTER>
<INPUT Type="Button" Name="cmdStart2" Value="Start 2">
</CENTER>
</FORM>
</BODY>
</HTML>
----- Original Message -----
Newsgroups: microsoft.public.scripting.vbscript
Sent: Thursday, June 08, 2000 12:00 PM
Subject: (newbie) how to access radio button in vbs?
Hi,
New to VBScript, fairly old-hand in VB6.
Can someone tell me how to define the click event for a rdio button within
a
group?? Normal buttons no problem, just use (say) "sub b1_onclick", but
what is the syntax if you have two radio buttons in a group, one with
groupname R1 value V1, one with groupname R1, value V2?? I've tried "sub
r1.v1_onclick", "sub r1(v1)_onclick" and get syntax error. "sub
r1_onclick"
or "sub v1_onclick" are accepted, but nothing happens.
Any advice welcomed
Thanks,
Roger
Hi,
New to VBScript, fairly old-hand in VB6.
Can someone tell me how to define the click event for a rdio button within
a
group?? Normal buttons no problem, just use (say) "sub b1_onclick", but
what is the syntax if you have two radio buttons in a group, one with
groupname R1 value V1, one with groupname R1, value V2?? I've tried "sub
r1.v1_onclick", "sub r1(v1)_onclick" and get syntax error. "sub
r1_onclick"
or "sub v1_onclick" are accepted, but nothing happens.
Any advice welcomed
Thanks,
Roger
Mayayana
2019-08-21 01:21:10 UTC
Permalink
"Rachel Phillips" <***@gmail.com> wrote

| how is this done in script for cscript.exe?

Did you realize you're posting to a post from 19 years ago?
You should get a real newsreader and stop using Google Groups.
Then you'll see current discussions.

I'm not clear what you're asking. None of the sample code
is radio buttons. Here's how I usually do it. You typically
don't need a click event because it's an option chosen
before they click a button:

<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE="VBScript">
Sub Op2_onclick()
If Op1(0).checked = True Then
MsgBox "first"
ElseIf Op1(1).checked = True Then
MsgBox "second"
Else
MsgBox "third"
End If
End Sub
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<INPUT TYPE="radio" ID="Op1" Name="Op1" checked>Radio1
<INPUT TYPE="radio" ID="Op1" Name="Op1">Radio2
<INPUT TYPE="radio" ID="Op1" Name="Op1">Radio3
<BR>
<INPUT TYPE="button" ID="Op2">Press
</BODY></HTML>

Continue reading on narkive:
Loading...