Cristian Raña Cristian Raña - 6 months ago 21
Vb.net Question

Selecting an item from a dropdown doesnt trigger any action with VB.net

I'm trying to automate loading data using vb.net, but there comes a point where I select values of various combobox. Seeing the code of the page I find that the combobox has a format similar to this(its just an example):

<select id="BirthMonth" name="BirthMonth">
<option value="">Month</option>

<option value="01" >January</option>

<option value="02" >February</option>

<option value="03" >March</option>

<option value="04" >April</option>


fails to work with
WebBrowser1.Document.GetElementById ("Name combo")
SetAttribute ("OPTION", "March")
, searching the Internet I found a solution where inter is a parameter that contains the value.:

Public Sub selector(ByVal inter)
Dim option_ As HtmlElementCollection
option_ = WebBrowser1.Document.GetElementsByTagName("option")

For Each option__ As HtmlElement In option_

If option__.InnerHtml = inter Then

option__.SetAttribute("selected", "True")

End If

Next
End Sub


which if you choose value, but the page does not take it, so it does not refresh the other
Combobox
.

Anyone know how to do to select the value, so the page can trigger the action?

PS: must be in the name of the field by value.

Thank you very much
Bye!

PS: I solved the problem just adding this lines after the selection:

WebBrowser1.AllowNavigation = True
WebBrowser1.Document.Forms(0).InvokeMember("submit")

Answer

Its solved just adding this lines after the selection:

WebBrowser1.AllowNavigation = True
WebBrowser1.Document.Forms(0).InvokeMember("submit")
Comments