Trigger javascript event with COM

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
nicocs29
Posts: 5
Joined: 19 Dec 2016, 22:09

Trigger javascript event with COM

26 Mar 2017, 17:05

Hello,

I have 2 select dropdown lists. The 1st one contains a list of states and the 2nd one a list of counties.

Whenever I manually select any state from the 1st list the 2nd one loads the list of the corresponding counties.

Using ahk I'm able to select the option I want from the 1st dropdown but the 2nd one never loads the corresponding counties for the state i selected, probably because the javascript event never fired.

Here's part of the html for the 1st dropdown:

Code: Select all

<select class="form-control" data-bind="dropdownList: states, dropdownCaption: 'Seleccionar estado', disableCaption: true, value: stateId, event: { change: onStateChange }"><option value="" disabled="" style="display: none;">Seleccionar estado</option><option value="1">Aguascalientes</option><option value="2">Baja California</option>
Here's the 2nd one when the page loads:

Code: Select all

<select class="form-control" data-bind="dropdownList: counties, dropdownCaption: 'Seleccionar municipio/delegación', disableCaption: true, value: countyId, event: { change: onCountyChange }"><option value="" disabled="" style="display: none;">Seleccionar municipio/delegación</option></select>
I'm able to select the option I want from the first dropdown with:

Code: Select all

pwb.document.getElementsByClassName("form-control")[1].Value := "22" ; Sets state
However the 2nd dropdown never populates with the list of counties for the selected option.

I've tried the following to no avail:

Code: Select all

pwb.document.getElementsByClassName("form-control")[1].fireEvent("onchange")
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Trigger javascript event with COM

27 Mar 2017, 00:39

try

Code: Select all

pwb.document.getElementsByClassName("form-control")[1].Value := "22" ; Sets state
pwb.document.getElementsByClassName("form-control")[1].onchange()    
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, septrinus, songdg and 255 guests