Use VBscript to populate a form in IE 8

5 pts.
Tags:
forms
VBScript
Web forms
I would like to use VBscript to populate pre-defined fields on forms from a website. I have written some code which should work but I must be missing something. Here is the code I have now:
DIM objBrowser DIM objForm

Set objBrowser = CreateObject("InternetExplorer.Application") objBrowser.navigate "https://accounts.craigslist.org/" objBrowser.Visible = True

While objBrowser.Busy   WScript.Sleep 50 Wend

Set objForm = objBrowser.document.getElementByID("Email / Handle:") objForm.Value = "sschtupak@hotmail.com" 'fill in the text box

WScript.Quit
The field is not populating and I get an "Object Required" error on the line that starts objForm.Value but this same code works on other sites (changed field values and website of course). Any help would be appreciated. Thanks in advance.

Software/Hardware used:
VBScript

Answer Wiki

Thanks. We'll let you know when a new response is added.

Most likely the problem is that this page doesn’t have an element with id “Email / Handle:”, and because of that, this line is failing:

Set objForm = objBrowser.document.getElementByID("Email / Handle:")

And thus, objForm doesn’t point to a valid object.

According to the documentation, getElementById could produce different results depending on the version of IE, because in IE 7 and below, it checks the ID and NAME attributes (case-insensitive), and in IE8 it checks the ID only (case-sensitive).

——–

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following