# Website not updating after inserting drop down option via VBA



## Kmanbozzy (Jan 5, 2019)

I've tired a lot of different approaches and still have not figured out any way to overcome the issue. When use the .selectedindex = 10, the option appears just like i wont it to, but the date range boxes will not appear after i've picked the option. ive tired .focus .fireevents .click and many other attempts. nothing i seem to do works. What i want to know is when i click on a drop down menu on a webiste, what is governing the following action of appearing the date ranges? is it a javascirpt function? If so where in the IE inspect element would i find where that function is being called after selecting an option from the drop down list? Then how would i call that function in VBA to appear those date ranges?

Here is my VBA code:

```
IE.document.getelementbyid("statementFilterDropDown").Focus
    IE.document.getelementbyid("statementFilterDropDown").selectedindex = 10
    IE.document.getelementbyid("statementFilterDropDown").fireEvent "onchange"
    IE.document.getelementbyid("statementFilterDropDown").Click
    IE.document.getelementbyid("dateRangeFrom").Value = StartDate
    IE.document.getelementbyid("dateRangeTo").Value = EndDate
```

The thing is, it all works once the date ranges are visible, which only happens after the option "date range" is chosen from the drop down menu manually. the .selectedindex = 10 works correctly, but just wont update the website to view the date ranges. 

here is the html script


----------



## Rijnsent (Jan 9, 2019)

Hi Kmanbozzy,
what is the URL you're trying to test your code on? Just the info you've provided is not enough for me to spot what goes wrong, for that I'd need to tinker a bit myself.
Cheers,
Koen


----------



## Kmanbozzy (Jan 9, 2019)

well its my bank account, so you wont be able to get to the screen unless you have the same bank, its citi bank is there anything i can get for you to make it easier?


----------



## Rijnsent (Jan 14, 2019)

Hi Kmanbozzy,
mmm, tough one. Don't have a Citibank account, so have no clue what code they are using, sorry, hope that someone else can help you on.
G'luck,
Koen


----------



## John_w (Jan 19, 2019)

Using your browser's developer tools (press the F12 key), see if the select element has any event(s).  Your code suggests that it has a 'change' event, in which case call dispatchEvent on it like this (reference to MS HTML Object Library is required):


```
Dim HTMLdoc As HTMLDocument
    Dim selectElement As HTMLSelectElement
    Dim changeEvent As Object
    
    'After IE page has fully loaded
    Set HTMLdoc = IE.document
    Set changeEvent = HTMLdoc.createEvent("HTMLEvents")
    changeEvent.initEvent "change", True, False
    
    Set selectElement = HTMLdoc.getElementById("statementFilterDropDown")
    selectElement.Focus
    selectElement.selectedIndex = 10
    selectElement.dispatchEvent changeEvent
    DoEvents
```


----------

