5 pts.
 Use VB Script to Populate a form in IE8
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:
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). --------
Last Wiki Answer Submitted:  January 11, 2010  10:58 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _