+ Reply to Thread
Results 1 to 9 of 9

Radio buttons in IE

Hybrid View

  1. #1
    Registered User
    Join Date
    07-31-2008
    Location
    Regina
    Posts
    8

    Radio buttons in IE

    Ok so i have been working on this file for quite some time and have been programming in Excel for work for quite some time but now i am stumped.

    I need to log into a website then go to a specific page and copy info from the page into excel. I wrote this code in about 5 minutes not a problem. Now that i have done that I have to get excel to click a radio button and hit the submit button. The problem is the only code i can get to work for this is very specific and you have to know the name and the value of the radio button in Internet explorer. This is a problem as the name of the button changes everytime you go to the page so does the value. Now part of the name stays the same but a number changes in the name and its not consecutive. Also there may not be a radio button at all but there maybe lots. think of it this way a list of new things you need to check and delete every hour the radio button selects delete and then you submit them. there maybe none for the hour or 100. this is my problem because unless I know the exact name i cant seem to get them to change maybe someone will know what to do. Here is my code for the exact name system to change the radio button.

    Set radio_button = IE.Document.all.Item("voice_mark_|1217541926|017|51")
    
    For Each rb In radio_button
    If rb.Value Like "S|L|" & "*" Then
    rb.Checked = True
    End If
    Next
    Let me know how i can select them if i dont know there name.

  2. #2
    Registered User
    Join Date
    07-31-2008
    Location
    Regina
    Posts
    8
    Ok so i think i maybe getting closer if I can just get the code to work.
    Based off some code i have ised previously i cam up with this:
    For Each vControl In IE.Document
    If vControl.Value Like "S|L|" & "*" Then
    vControl.Checked = True
    End If
    Next
    Unfortunatly this did not work either as VControl is for VB and not for java i realy dont know what to use in its stead. IE.Doc dosnt work either as far as i can tell this only signifys the html doc not the form itself. So i guess i have to conintue working on this any added info anyone can provide would be great.

  3. #3
    Registered User
    Join Date
    07-31-2008
    Location
    Regina
    Posts
    8
    Still working on getting this right have not been able to get any closer than the last post in getting this to work. Any help would be appriecated

  4. #4
    Forum Contributor
    Join Date
    07-01-2008
    Location
    Cincinnati, OH
    Posts
    150
    Hi Manni.

    Please post the HTML source. There are a number of ways to obtain a reference to an element without knowing the name.

    What is the criteria for setting the values of your input elements to true? Are they all true? Are the radiobuttons grouped in such as way that selecting one sets the value of others to false?

    Modifying your example...
    For Each vControl In IE.Document
    If vControl.Value Like "S|L|" & "*" Then
    vControl.Checked = True
    End If
    Next
    To...
        Dim RadioButton As Object 'HTMLInputElement
    
        For Each RadioButton In IE.Document.forms(0).getElementsByTagName("INPUT")
            If RadioButton.Name Like "S|L|*" Then
                RadioButton.Checked = True
            End If
        Next

  5. #5
    Registered User
    Join Date
    07-31-2008
    Location
    Regina
    Posts
    8
    I can give you some of the html code you are looking for unfortuanatly due to the nature of the website we cannot give everything but the code you are looking for is like this.

    &nbsp;&nbsp;<input type="radio" class="check" name="voice_mark_|1218069880|014|21" value="L|N|1218069880001421|122">&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" class="check" name="voice_mark_|1218069880|014|21" value="S|N|1218069880001421|122">&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" class="check" name="voice_mark_|1218069880|014|21" value="D|N|1218069880001421|122">&nbsp;&nbsp;&nbsp;</td><td></td></tr>
    this is one set of linked radio buttons bt there could be more sets they will look exactly like this but there names and values will be slightly different. The Value of the one I will need will always start with L|N| but that is all. this is what has been making it so tough i will work with the code you gave me and see if i can get that to work or with this code if you could come up with something let me know. If you need more code i could make a mock of what we have but it would take quite some time so i hope this will do.

  6. #6
    Forum Contributor
    Join Date
    07-01-2008
    Location
    Cincinnati, OH
    Posts
    150
        Dim RadioButton As Object 'HTMLInputElement
    
        For Each RadioButton In IE.Document.forms(0).getElementsByTagName("INPUT")
            If RadioButton.Value Like "S|L|*" Then
                RadioButton.Checked = True
            End If
        Next

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1