如何在webbrowser控件中更改下拉框? [英] How do I change a dropdown box in a webbrowser control?

查看:151
本文介绍了如何在webbrowser控件中更改下拉框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个我想要更改的列表框,看起来像这样:

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

如何更改7月的值?我需要这个100%自动化,并将其更改为1月。我在各种网站上做了很多帐户,需要将它们全部改回同一个生日。是的,我知道我必须找到它的ID等。

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.

推荐答案

查看网站的HTML并确定下拉列表中的 id ,例如:

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>

要在WebBrowser控件中预先选择dropdownlist值,请使用此Winform代码:

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

webBrowser1.Document.GetElementById("bdayMonthId").SetAttribute("value", "Feb");

这篇关于如何在webbrowser控件中更改下拉框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆