Reputation: 978
I am trying to navigate a website and perform activities based on input from Excel.
I am stuck in passing values to input element which auto populates value in next text box based on value we have passed (eg: if I pass a zip code in target box then city name is auto populated in next box). I can pass values but it is not triggering the JS which auto populates value.
Target box code in webpage
<input name="zipcode" class="inputBoxRequired" id="zipcode" onkeypress="return isNumberKey(event)" onblur="getZipCity(this.value,'/ProviderPortal')" type="text" size="46" maxlength="5">
Code tried
Set Zip = ie_Doc.getElementById("zipcode")
Zip.Value = Zip_Code 'Here value gets updated but associated js is not triggered
ie_Doc.getElementById("zipcode").Focus
even tried fire event
Zip.FireEvent ("onchange")
In webpage it is mentioned as Onkeypress event. I googled to find solution but I can't get exact one.
Upvotes: 3
Views: 1700
Reputation: 860
I have come across the same scenario for solution verified this post whereas in my case I do not have "onblur" tag, so I did some search and come up with an solution.
Dim event_onChange As Object
Set event_onChange = ie_Doc.createEvent("HTMLEvents")
event_onChange.initEvent "keypress", True, False
Zip.dispatchEvent event_onChange
It will help others who are facing same problem.
Upvotes: 1
Reputation: 84475
Zip.FireEvent ("onkeypress")
Zip.FireEvent ("onblur") '<== Apparently this did the trick
Those are the shown events.
Upvotes: 4