PDA

View Full Version : IE Automation form Javascript



ThatGuy
01-30-2009, 09:40 AM
I am trying to fill in a Javascript form and have run into an issue. I have with muliple drop downs. Each drop down's data is based on the selection of the previous drop down.

I am able to fill in the first drop down using the below code. However, it dies not update drop down below it. I tried forcing my value into the second drop down but it errors out.

I cannot post the html code as it contains confidential information and I am not familiar with javascript so I do not know what part would be important and which ones would not be.

Here is my code:

Sub GoToWebSiteUpdate()
Dim appIE As InternetExplorer
Dim sURL As String
Dim UserN As Variant
Dim myLoginID As String

Set appIE = New InternetExplorer
sURL = "mysite"
With appIE
.Navigate sURL 'Go to Login page
.Visible = True 'Show IE

'Enter information in the first drop down
Set UserN = appIE.document.getElementsByName("dropdown1")
UserN(0).Value = "Answer1"

'Enter information in the second drop down
Set UserN = appIE.document.getElementsByName("dropdown2")
UserN(0).Value = "Answer2"

end with

Set appIE = Nothing
End Sub


Any ideas?

I eventually plan on posting my entire code IE Automation to help others who may be trying to fill in advanced forms.

lucas
01-30-2009, 10:04 AM
Are you running this from Excel?

ThatGuy
01-30-2009, 11:17 AM
Are you running this from Excel?

Yes, that is why I posted under the VBA > Excel. :yes

ThatGuy
01-30-2009, 07:50 PM
I found an site that performs a similar action.

On the site when you select a drop down option it automatically puts in a price. When I change the value of select an item by code it does not populate the amounts.

I also tested another code to select and it still did not work:

Set UserN = appIE.document.getElementsByName("prodchosen1")
UserN(0).Item(1).Selected = True


Anyone know how I can force it to update?