|
-
Jun 23rd, 2001, 08:16 AM
#1
MS WebBrowser & JavaScript Radio Button
Hello everyone!
I got a problem with my Program. It's used to fill out JavaScript forms in Webpages, and uses the MS WebBrowser provided in my VB 6.0. It's my first Internet project, and I did quite well until now via learning by doing. My problem:
When a page has some radio buttons, they all have the same name, i.e.:
<INPUT type="radio" name="sex" value="male">
<INPUT type="radio" name="sex" value="female">
Usually, I access the form elements this way:
WebBrowser1.document.forms.FORMNAME.ELEMENTNAME.value="VALUE"
So normally, it would be
WebBrowser1.document.forms.userinfo.sex.value="male"
BUT THIS DOESN'T WORK...
Is there anybody who could help me? It's really urgent because it is for my teacher and I don't want to tell him I didn't manage it... So PLEASE help!!!!
Until then - Knele
-
Jun 24th, 2001, 03:08 AM
#2
Hyperactive Member
The radio buttons form a collection. You MUST have an INDEX to the ITEM in the collection AND if you want to turn it on or off the CHECKED boolean property must be used. Here is VB code in a SUB that I use to locate the radio button according to the NAME and VALUE that will be sent and set CHECKED to true. I do not use a specific object type except for Webbrowser and Document
Code:
Dim objElements As Object
Dim objElement As Object
Dim I As Long
Select Case LCase(strElementType)
Case "select", "radio"
Set objElements = Webbrowser1.Document.All(strElementName)
If Err.Number <> 0 Then Exit Do
For Each objElement in ObjElements
If objElement.Value = strElementValue Then
If LCase(strElementType) = "radio" Then
objElement.Checked = True
Else
objElement.Selected = True
End If
Exit For
End If
Next
-
Jun 24th, 2001, 04:11 AM
#3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|