Automatically select field

1

Personal I have a field:

IsettoautomaticallyfillinVB:

Me.WebBrowser1.Document.GetElementsByTagName("select").GetElementsByName("NW_State").Item(0).SetAttribute("value", "AK")

But it's not going to work, I've tried it in many ways.

    
asked by anonymous 27.04.2015 / 07:54

1 answer

0

You can retrieve child items from select and iterate through them by selecting the one that has the searched text:

Dim htmlElm As HtmlElement = Me.WebBrowser1.Document.GetElementsByTagName("select").GetElementsByName("NW_State").Item(0)
    For Each item As HtmlElement In htmlElm.Children
        If (item.InnerHtml = "AZ") Then
            item.SetAttribute("selected", "selected")
        Else
            item.SetAttribute("selected", String.Empty)
        End If
    Next
    
27.04.2015 / 19:02