如何使用webbrowser填充第二个组合框?我可以选择第一个组合框的第一个选项,但它不启用第二个列表。我已经研究过html代码,但我没有找到javascript或ajax函数。
以下HTML代码:
<select aria-required='true' class='form-field form-field-select form-field-medium' id='state' name='state'>
<option value='0'>Selecione</option>
<option value='25'>Acre</option>
<option value='16'>Alagoas</option>
<option value='26'>Amapá</option>
<option value='15'>Amazonas</option>
<option value='4'>Bahia</option>
<option value='8'>Ceará</option>
<option value='20'>Distrito Federal</option>
<option value='14'>Espírito Santo</option>
<option value='12'>Goiás</option>
<option value='10'>Maranhão</option>
<option value='19'>Mato Grosso</option>
<option value='21'>Mato Grosso do Sul</option>
<option value='2'>Minas Gerais</option>
<option value='9'>Pará</option>
<option value='13'>Paraíba</option>
<option value='6'>Paraná</option>
<option value='7'>Pernambuco</option>
<option value='17'>Piauí</option>
<option value='3'>Rio de Janeiro</option>
<option value='18'>Rio Grande do Norte</option>
<option value='5'>Rio Grande do Sul</option>
<option value='23'>Rondônia</option>
<option value='27'>Roraima</option>
<option value='11'>Santa Catarina</option>
<option value='1'>São Paulo</option>
<option value='22'>Sergipe</option>
<option value='24'>Tocantins</option>
</select>
第二个下拉代码
<select aria-required="true" class="form-field form-field-select form-field-medium" id="region" name="region">
<option value="">Selecione</option>
<option value="11">DDD 11 - São Paulo e região</option>
<option value="12">DDD 12 - V. do Paraíba e Litoral Norte</option>
<option value="13">DDD 13 - Baixada Santista e Litoral Sul</option>
<option value="14">DDD 14 - Bauru, Marília e região</option>
<option value="15">DDD 15 - Sorocaba e região</option>
<option value="16">DDD 16 - Ribeirão Preto e região</option>
<option value="17">DDD 17 - S. José do Rio Preto e região</option>
<option value="18">DDD 18 - Presidente Prudente e região</option>
<option value="19">DDD 19 - Grande Campinas</option>
</select>
使用此代码我无法选择第一个下拉菜单,但它无法让我选择第二个。
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("select"))
{
if (el.Name == "state")
{
foreach (HtmlElement comboItem in el.Children)
{
Console.WriteLine(comboItem.InnerText + " " + comboItem.GetAttribute("Selected"));
if (comboItem.InnerText == "São Paulo")
{
comboItem.SetAttribute("selected", "true");
SendKeys.Send("\t");
}
}
}
//SendKeys.Send("+{Tab}");
//SendKeys.Send("{ENTER}");
}
谁想要看到链接为LINK
的网页