3

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.

7
  • Can you share the URL please? Commented Oct 23, 2018 at 13:25
  • sorry @QHarr its an secure web portal I am not able to share the URL , need to sign in to view the page I am taking about. Commented Oct 23, 2018 at 13:36
  • Did you fire the onBlur as well? And for some of these things they expect key press that are best mimicked by .Focus first then .Sendkeys "Text"..... dreaded as sendkeys are. Commented Oct 23, 2018 at 13:37
  • how should I do it please suggest Commented Oct 23, 2018 at 13:39
  • Zip.FireEvent ("onkeypress") : Zip.FireEvent ("onblur") Commented Oct 23, 2018 at 13:40

2 Answers 2

4
Zip.FireEvent ("onkeypress")
Zip.FireEvent ("onblur")  '<== Apparently this did the trick

Those are the shown events.

Sign up to request clarification or add additional context in comments.

1 Comment

Why doesn't this answer get the same upvotes as the question recieved? Nice finding again @QHarr.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.