Radio buttons in VBScript

I know this is an often asked question, but I can't seem to find an answer that fits my simple needs.
I'm wrtiing a VBscript which requires to get user input from a list of choices. It seems the proper way is to use an external HTA file.
But I don't know how this should look like.

So if anyone could give me a basic example of a VBScript obtaining user answers from an HTA file, it would help a lot.

Who is Participating?
TakedaTConnect With a Mentor Commented:
I played a bit.  Here is what I came up with.  It shouldnt be difficult to customize it to your needs.  I hope this is what you were looking for.
strRadio = GetRadioAnswer( "Please check an option" )
WScript.Echo strRadio

Function GetRadioAnswer( myPrompt )
    Dim objIE
    Set objIE = CreateObject( "InternetExplorer.Application" )
    objIE.Navigate "about:blank"
    objIE.Document.Title = "Get Radio Option"
    objIE.ToolBar        = False
    objIE.Resizable      = False
    objIE.StatusBar      = False
    objIE.Width          = 320
    objIE.Height         = 180
    With objIE.Document.ParentWindow.Screen
        objIE.Left = (.AvailWidth  - objIE.Width ) \ 2
        objIE.Top  = (.Availheight - objIE.Height) \ 2
    End With
    Do While objIE.Busy
        WScript.Sleep 200
	objIE.Document.Body.InnerHTML = "<DIV align=""center"">"&myPrompt&"<P><input type='radio' name='RadioOption' value='1'>1<BR>"&_
		"<input type='radio' name='RadioOption' value='2'>2<BR>"&_
		"<input type='radio' name='RadioOption' value='3'>3<br>"&_
		"<input id='OK' type='hidden' value='0' name='OK'>"&_
		"<input type='submit' value='OK' onClick='VBScript:OK.Value=1'>"
    objIE.Visible = True
    Do While objIE.Document.All.OK.Value = 0
        WScript.Sleep 200
    If objIE.Document.All.RadioOption(0).checked=true then GetRadioAnswer="first is checked"
    If objIE.Document.All.RadioOption(1).checked=true then GetRadioAnswer="second is checked"
    If objIE.Document.All.RadioOption(2).checked=true then GetRadioAnswer="third is checked"
    Set objIE = Nothing
End Function

Open in new window

Check out this link.  It is as basic as it can get and should help you out.
fhmsolutionsAuthor Commented:
Thanks, but this shows an HTA that includes VBscript. I need the opposite.
In sequence : The VBS launches the HTA
The HTA shows the buttons, then gets the answer from the user
The VBS gets the information back and goes on
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Thats an interesting idea, but Im not sure how to approach it.  I dont think it is possible with an .hta, but it may be possible using the InternetExplorer.Application object.  I will play and see what I can do.
fhmsolutionsAuthor Commented:
Thanks. I know it's been done before.
I found some information about it here :
But I'm not good enough with both VBScript and HTA to adapt this to my needs.

fhmsolutionsAuthor Commented:
Thanks a lot. That was exactly what I needed. I adapted it to my needs and it works perfectly.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.