Use VB Script to Populate a form in IE8

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" erro 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
ASKED: January 11, 2010  7:27 PM
UPDATED: January 11, 2010  10:58 PM

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 <b>id</b> “Email / Handle:”, and because of that, this line is failing:

<pre>Set objForm = objBrowser.document.getElementByID(“Email / Handle:”)</pre>

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

According to <a href=”http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx”>the documentation</a>, 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:

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