I'm working on a webpage automation project. And I am very new in this. I want to use Webbrowser control to select an item in the dropdownlist. Now,how do I programmetically select an item from the HTML snippet below. I would like to select,say for example,"2009" from this HTML code :

<select name = "yr">
<option value= "">Year</option>

I am trying the following code :

      For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("select")
                If element.GetAttribute("name") = "yr" Then
                    element.SetAttribute("value", "2011")
                End If


Thanks in advance for any help.

Recommended Answers

All 2 Replies

I think you will have to try passing Javascript code in with your HTML stream and do it that way.

java script code will be the best to use in this case......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.