1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

selecting option value with webbrowser

Discussion in 'Visual Basic .NET' started by astradamasta, Apr 15, 2009.

  1. astradamasta

    astradamasta Registered Member

    Joined:
    Nov 24, 2008
    Messages:
    56
    Likes Received:
    8
    I am pretty familiar with how to use the webbrowser control. I know how to autofill forms using the getelementbyid code but I'm having a problem selecting from drop down menus.

    Here is the html source code:

    <select name="birthday_mon">

    <option value="0">---</option>
    <option value="1">January</option>
    <option value="2">February</option>
    <option value="3">March</option>

    <option value="4">April</option>
    <option value="5">May</option>


    how would i go about selecting any of those values. thanks in advance
     
  2. wowmanwow

    wowmanwow Registered Member

    Joined:
    Nov 7, 2008
    Messages:
    60
    Likes Received:
    12
    It's done the same exact way. Just change the ID to "birthday_mon" and the value to "3" or whatever number you want.
     
  3. OhaiBBQ

    OhaiBBQ Newbie

    Joined:
    May 26, 2009
    Messages:
    25
    Likes Received:
    35
    Sorry if this is considered gravedigging, apparently no one codes in .NET anymore xD

    I used to have this trouble while making bots for freebies, here is my solution:

    I use a combobox in this case the items would be:
    Code:
      1-January
      2-February
      3-March
      4-April
      5-May
    
    Then I would get the element and set the attribute like this

    Code:
    webbrowser1.Document.GetElementbyId("birthday_mon").SetAttribute("value", ComboBox1.SelectedItem.ToString.Remove(ComboBox1.SelectedItem.ToString.Indexof("-"), ComboBox1.SelectedItem.ToString.Length - 1)
    
    Sort of long and inefficient, I know but eh, it works : )

    Hope I helped

    -OhaiBBQ