Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(newbie) how to access radio button in vbs?

210 views
Skip to first unread message

Roger Staff

unread,
Jun 8, 2000, 3:00:00 AM6/8/00
to
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

Dionigi

unread,
Jun 8, 2000, 3:00:00 AM6/8/00
to
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>

Roger Staff <rog...@rhmtech.co.uk> wrote in message
960458245.18367.0...@news.demon.co.uk...

Rachel Phillips

unread,
Aug 20, 2019, 5:41:12 PM8/20/19
to
how is this done in script for cscript.exe?

Mayayana

unread,
Aug 20, 2019, 9:22:14 PM8/20/19
to
"Rachel Phillips" <rmani...@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>


0 new messages