Jump to content
meow

onChange event on a webpage combox

Recommended Posts

Hey guys,

 

So I'm in a hockey pool at work and we have our own little program reading the NHL stats on their website. It's been working for years.

 

Here's the link to the NHL stats: http://www.nhl.com/stats/player?aggregate=1&gameType=2&report=skatersummary&pos=S&reportType=season&seasonFrom=20162017&seasonTo=20162017&filter=gamesPlayed,gte,1&sort=points,goals,assists

 

The problem now is that NHL changed the way to navigate to the next page. Last year it was a "next" link button. So we'd find that button and call the "click" event on it.

 

But as you can see in the link, at the bottom...it is now a combobox...and I can't seem to fire the onChange event. I can change the value just fine...but it won't go to the next page of stats.

 

 

Here's a quick and easy example of code in vb.net (please do not waste time judging the code or whatever, I'm just trying to find a way to fire the onChange event).

I have tried many ways that I found on google, but nothing seems to work. Anyone nice enough to try it out or tell me how to do it? Thanks.

 

I dont know whats wrong with the colors in the spoiler tag lol. just copy paste in vb.net

 

 

Imports SHDocVw
Imports MSHTML

Module Module1

    Sub Main()
        Dim ie As InternetExplorer

        ie = New InternetExplorer
        ie.Visible = True

        ie.Navigate("http://www.nhl.com/stats/player?aggregate=1&gameType=2&report=skatersummary&pos=S&reportType=season&seasonFrom=20162017&seasonTo=20162017&filter=gamesPlayed,gte,1&sort=points,goals,assists")

        Do
        Loop Until ie.ReadyState = tagREADYSTATE.READYSTATE_COMPLETE

        Dim all As IHTMLElementCollection
        all = ie.Document.all

        For Each elem As IHTMLElement3 In all
            If elem.className = "page-select-container" Then
                Dim pagerSelect As IHTMLSelectElement
                pagerSelect = elem.all(0) 'get the combobox

                pagerSelect.selectedIndex = 2 ' <--- This changes the value in the combox


                ''''the onchange event never works...
                pagerSelect.FireEvent("onChange", pagerSelect)
                pagerSelect.FireEvent("onChange")
                ''''
            End If
        Next

        ie.Quit()
    End Sub

End Module

 

 

Share this post


Link to post
Share on other sites

uugh and by combox i meant combobox....man i cant spell

Share this post


Link to post
Share on other sites

You could use something like selenium with Java.


I realize that's probably not necessarily what you're looking for but it could be easier and more efficient down the road.

Share this post


Link to post
Share on other sites

You could use something like selenium with Java.

I realize that's probably not necessarily what you're looking for but it could be easier and more efficient down the road.

 

That's actually interesting.

 

But our hockey pool program is not my own and it works in VBA Excel and no one wants to redo it all.

 

Thanks for sharing though

Share this post


Link to post
Share on other sites

That's actually interesting.

 

But our hockey pool program is not my own and it works in VBA Excel and no one wants to redo it all.

 

Thanks for sharing though

I don't much know about VBA unfortunately, otherwise I'd be more than willing to help. I just know that we use Selenium for RTA at work, though come to think of it, that may not be the best approach for this.

 

That being said, have you considered getting the data differently? Rather than working with the page's elements, couldn't you work with some sort of API or query to get the results in a less bloated way?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


About Us

We are glad you decided to stop by our website and servers. At Fearless Assassins Gaming Community (=F|A=) we strive to bring you the best gaming experience possible. With helpful admins, custom maps and good server regulars your gaming experience should be grand! We love to have fun by playing online games especially W:ET, Call of Duty Series, Counter Strike: Series, Minecraft, Insurgency, DOI, Sandstorm, RUST, Team Fortress Series & Battlefield Series and if you like to do same then join us! Here, you can make worldwide friends while enjoying the game. Anyone from any race and country speaking any language can join our Discord and gaming servers. We have clan members from US, Canada, Europe, Sri Lanka, India, Japan, Australia, Brazil, UK, Austria, Poland, Finland, Turkey, Russia, Finland, Germany and many other countries. It doesn't matter how much good you are in the game or how much good English you speak. We believe in making new friends from all over the world. If you want to have fun and want to make new friends join up our gaming servers and our VoIP servers any day and at any time. At =F|A= we are all players first and then admins when someone needs our help or support on server.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.