WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Click on Button with No Name and No ID

 Keywords:  

HTML form with a button that doesn't contain an ID attribute or a NAME attribute:
<html>
<head></head>
<body>

<form action="http://www.winbatch.com">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

You can reference the form input using its item number like this:

#DefineFunction udfStartMSIE(url)
   ; starts the browser and navigates to specified URL...
   objBrowser = ObjectCreate("InternetExplorer.Application")
   objBrowser.visible = @TRUE
   objBrowser.navigate(url)
   udfWaitForPageLoad(objBrowser)
;   return a reference to the browser object...
   Return(objBrowser)
#EndFunction

#DefineFunction udfWaitForPageLoad(objBrowser)
   ; Waits for webpage to load
   While objBrowser.busy || objBrowser.readystate == 1
      TimeDelay(0.5)
   EndWhile
   While objBrowser.Document.ReadyState != "complete"
      TimeDelay(0.5)
   EndWhile
   Return
#EndFunction

url = DirScript():'IE9_Test.html'
objBrowser = udfStartMSIE(url)

; Fill in Form Data
objBrowser.document.getElementById('fname').value = 'John'
objBrowser.document.getElementById('lname').value = 'Doe'
; If your button has no NAME or ID attribute
objBrowser.document.GetElementsByTagName("INPUT").Item(2).click

objBrowser = 0
Exit

Article ID:   W18126
Filename:   Click on Button with No Name and No ID.txt
File Created: 2011:04:01:08:21:54
Last Updated: 2011:04:01:08:21:54