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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE automation - element name problem

Status
Not open for further replies.

mkrausnick

Programmer
Apr 2, 2002
766
US
Using VFP9, I log into a web site automatically and retrieve status information on insurance applications. The web site is not under my control. They recently re-wrote the login page ad changed the name of the user id and password fields, which of course broke my login routine. The login used to say:
Code:
oIE.document.Forms(1).UserID.value = lcUserID
oIE.document.Forms(1).UserPW.value = lcUserPW

They changed the ids of the fields to "3DUserID" and "3DUserPW" respectively. However, the statements:

Code:
oIE.document.Forms(1).[b][red]3D[/red][/b]UserID.value = lcUserID
oIE.document.Forms(1).[b][red]3D[/red][/b]UserPW.value = lcUserPW

fail with the message "syntax error". The problem is that the field IDs begin with a number. If I remove the '3' I get "name not found", which is what I would expect, since the name without the leading '3' is wrong.

I think this is a VFP syntax error, not an HTML syntax error. Is there another way to specify the field IDs that would make VFP happy?




Mike Krausnick
Dublin, California
 
An interesting problem, Mike. I wonder why the insurance company changed the document in that way.

You should be able to fix this by looping through the form's Elements collection. This is off the cuff and un-tested, but something along these lines:

Code:
FOR EACH loItem IN oOE.Documents.Forms(1).Elements
  IF loItem.Name = "3DUserID"
    loItem.Value = lcUserID
  ENDIF
  * similarly for pwd
ENDFOR

I'm really not sure if this is correct, but it should give you something to work on.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Try this also.

oIE.Document.all.item("3DUserID").value = lcUserID
oIE.Document.all.item("3DPassword").value = lcPassword

Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top