开发者

Webbrowser - update second dropdown list after choosing an item from the first dropdown list

My goal is to update second dropdown list which is updated after choosing an item from the first dropdown list. Any help would be appreciated. I can't detect when start ajax activity in webbrowser control. I've tried instructions in this thread with no success, implemented the following class: HTML:

<html>
<Head>
<script type="text/javascript" src="http://myweb.com/scripts/jqu开发者_Go百科ery_1.5.js">
</head>
<body>
<select id =”cboCity”>
<option value=”1”> C1 </option>
<option value=”2”> C2 </option>
<option value=”3”> C3 </option>
<select id =”cboDistrict”>
<option value=”1”> D1 </option>
<option value=”2”> D2 </option>
<option value=”3”> D3 </option>
</body>
</html>

C# Code:

System.Windows.Forms.Timer timer1;
HtmlElement city = webbrowser1.doc.GetElementById("cboCity ");
      city.Focus();
      city.SetAttribute("value", "2");
      city.InvokeMember("onchange");

      timer1 = new System.Windows.Forms.Timer();
      timer1.Tick +=new EventHandler(timer1_Tick);
      timer1.Interval = 1000;
      timer1.Enabled = true;
      timer1.Start();

private void timer1_Tick(object sender, EventArgs e)
    {
      HtmlElement district = webbrowser1.doc.GetElementById("cboDistrict");
      district.Focus();
      district.SetAttribute("value", "3");
      district.InvokeMember("onchange");

      timer1.Stop();
      this.timer1.Enabled = false;
    }


You can use jquery to do that.

$(function() {
    $("#cboCity").change(function() {
        var currentSelection = $(this).val();
//grab the other items
//loop trough them
//inert into $("cboDistrict").html();
    });
});


Why not use jQuery and the change even on the dropdown? http://api.jquery.com/change/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜