none
How to check radio button state on strange html source?

    Question

  • Hi all.

    I would like to find out which tag is selected.  The problem is that the html source does not contain words such as "selected".

    How to solve it? I noticed that when I use the following code I get information about all avaible radio (count = 4)

    Page based probably on Ajax.

    WebBrowser1.Document.GetElementsByTagName("input").GetElementsByName("Firewall.SelectedLevel").Count

    a piece of html code below

    <h5><input type="radio" name="Firewall.SelectedLevel" value="Low" style="margin-left:10px;" class="firewall.low"/> <span style="; left:70px;" class="firewall.label.low"></span></h5> <div style="padding-left:50px;" class="firewall.low"></div><br/> <h5><input type="radio" name="Firewall.SelectedLevel" value="Medium" style="margin-left:10px;" class="firewall.medium"/> <span style="; left:70px;" class="firewall.label.medium"></span></h5> <div style="padding-left:50px;" class="firewall.medium"></div><br/>



    • Edited by _Artek_ Saturday, September 14, 2013 5:39 AM
    Friday, September 13, 2013 12:17 PM

Answers

  • Hi,

    In order to solve your issue, I suggest you have a look at the code below.

     For Each iradio As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input").GetElementsByName("Firewall.SelectedLevel")
                If iradio.GetAttribute("checked") = True Then
                    Label1.Text = iradio.GetAttribute("value") & " is checked"
                End If
            Next

    The following image shows the result of the code.

    Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 16, 2013 9:02 AM