Change Webpage ComboBox Element...-VBForums
Results 1 to 5 of 5

Thread: Change Webpage ComboBox Element...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Change Webpage ComboBox Element...

    I would like to change the Season Selector on a Netflix webpage to any of the available seasons via code.
    Here is a page to use: http://www.netflix.com/WiMovie/70158329

    I can get it to Click the button:

    Code:
    Web1.Document.getElementByid("selectorButton").Click
    But I can't seem to get it to change the Season list to another season.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Change Webpage ComboBox Element...

    Testing 1, 2, 3... is this thing on?

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,034

    Re: Change Webpage ComboBox Element...

    But I can't seem to get it to change
    you must select the item by index
    else loop through the items to find the match
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Change Webpage ComboBox Element...

    Your answer gave me nothing to work with. I know WHAT I need to do, I just don't know HOW to do it.

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,072

    Re: Change Webpage ComboBox Element...

    This should help give you an idea of how to do what you want

    Code:
    Dim MyURL As String
    
    Private Sub Command1_Click()
     MyURL = App.Path & "\Test.html"
    
     WebBrowser1.Navigate MyURL
    End Sub
    
    Private Sub Form_Load()
     MyURL = "NOTHING"
    End Sub
    
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
     If InStr(URL, MyURL) > 0 Then
       '
       ' Change the value= argument of the combo box
       '
       WebBrowser1.Document.All("mycombo").Options(0).Value = ""
       WebBrowser1.Document.All("mycombo").Options(1).Value = "Friend"
       WebBrowser1.Document.All("mycombo").Options(2).Value = "Movie"
       WebBrowser1.Document.All("mycombo").Options(3).Value = "Shopping"
       WebBrowser1.Document.All("mycombo").Options(4).Value = "TV"
       WebBrowser1.Document.All("mycombo").Options(5).Value = "Golf"
       
       '
       ' Change the text of the dropdown items of the combo box
       '
       WebBrowser1.Document.All("mycombo").Options(0).innerText = "**Select One**"
       WebBrowser1.Document.All("mycombo").Options(1).innerText = "[Friend's House]"
       WebBrowser1.Document.All("mycombo").Options(2).innerText = "[Movie Show]"
       WebBrowser1.Document.All("mycombo").Options(3).innerText = "[Shopping]"
       WebBrowser1.Document.All("mycombo").Options(4).innerText = "[Watching TV]"
       WebBrowser1.Document.All("mycombo").Options(5).innerText = "[Playing Golf]"
       
       '
       ' Make the 3rd item in the dropdown the current selected item
       '
       WebBrowser1.Document.All("mycombo").Options(3).Selected = True
     End If
    End Sub
    Below is the HTML that was used in the above example

    Test.html

    Code:
    <html>
    <body>
    
    <SCRIPT type=text/javascript>
    function menu_goto_footer(menuform)
    {					
     selecteditem = menuform.footer_links.selectedIndex;
    
     varLinks = menuform.footer_links.options[ selecteditem ].value;
     varTitle = menuform.footer_links.options[ selecteditem ].title;
    
     if (varLinks.length != 0 && varLinks != varTitle && varLinks != '#')
     {
      //location.href = varLinks;
      window.open(varLinks,'','');
     }
     else if(varLinks != '#')
     {
      window.open(varLinks,'','');
     }
    }
    </SCRIPT>
    
    
    
    
    <form>
    <SELECT onchange=menu_goto_footer(this.form) name=mycombo>
    <option value="">(no prefix)</option>
    <option value="home" >[Home]</option>
    <option value="school" >[School]</option>
    <option value="working" >[working]</option>
    <option value="studing" >[Studying]</option>
    <option value="playing" >[Playing]</option>
    </select>
    <form>
    
    </body>
    </html>

    I didn't use the link you posted because the page data is too long and this one is very small but it should give you the idea of how to do it
    Last edited by jmsrickland; May 20th, 2015 at 12:14 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.