Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form manipulation via VBS - need form to update after 1st selection

Status
Not open for further replies.

Drivium

Technical User
Oct 6, 2011
46
0
0
US
I created a script to BEGIN to do what I need. This script interacts with the initial form. I can fill out the form and submit, but it errors. Upon further inspection, after a selection is made in the first dropdown field, the form is supposed to refresh with updated dropdown options. With my code, it doesn't allow the form to refresh after the first selection is made. Here is my somewhat-working code:

[pre]set ie = createobject("internetexplorer.application")
Set objShell = CreateObject("WScript.Shell")

ie.navigate "ie.Visible = True
do until ie.readystate = 4 : wscript.sleep 10: loop

IE.Document.getElementsByTagName("select")("Board").Value = "25"
do until ie.readystate = 4 : wscript.sleep 10: loop
IE.Document.getElementsByTagName("select")("County").Value = "11"
IE.Document.getElementsByTagName("select")("RecsPerPage").Value = "50"

For Each btn In IE.Document.getElementsByTagName("input")
If btn.type = "image" Then
btn.Click()
Next
[/pre]
My question is - how do I allow the form to update after the first selection? First selection being:
[pre]
IE.Document.getElementsByTagName("select")("Board").Value = "25"[/pre]

I tried adding this after, but no dice:

[pre]do until ie.readystate = 4 : wscript.sleep 10: loop[/pre]

Thanks in advance
 
Does my question make sense? I'm happy to clarify. TIA!
 
I don't know what events are triggered (if any) while javascript updates a select input based on another selection, as this site does. If nothing else, you could try:
Code:
While IE.Busy
   WScript.Sleep 1000 'delay 1 second
Wend

... or just set a delay long enough to get it to work, but it may fail if the delay is not long enough.
Code:
WScript.Sleep 1000 'delay 1 second
 
Yea, I tried a delay. I think I need to reference some time of form function, but not sure how to do that. If you go to that link and select an object in the first drop down, you see the subsequent dropdowns change. I have to trigger THAT somehow...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top