Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change a dropdown box in a webbrowser control?

So I have a listbox I want to change, that looks like this:

enter image description here

How do I change the July value? I need this to be 100% automated and change it to January. I made a lot of accounts on various websites and need to change them all back to the same birthdate. Yes, I'm aware I'll have to find the ID of it, etc.

like image 625
Jon Avatar asked Feb 19 '23 07:02

Jon


1 Answers

View the HTML of the website and identify the id and values of the dropdownlist, for example:

<select id="bdayMonthId" size="1" name="bdayMonth">
    <option value="">Month</>
    <option value="Jan">January</>
    <option value="Feb">February</>
    <option value="Mar">March</>
</select>

To pre-select the dropdownlist value in the WebBrowser control use this Winform code:

webBrowser1.Document.GetElementById("bdayMonthId").SetAttribute("value", "Feb");
like image 188
Jeremy Thompson Avatar answered Mar 04 '23 17:03

Jeremy Thompson