By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,625 Members | 1,274 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,625 IT Pros & Developers. It's quick & easy.

How to loop through multiple FORMs?

P: n/a
Using DOM in IE (SHDocVw), how can I loop through FORMs and access FORM
elements in a specific form? For example, www.hotmail.com has about 13
forms. I believe the one displayed is dependent on the URL. If I want to
access the submit button of the visible form, which is usually the last one,
how is that done?

Currently, I look for type=submit using DOM but it doesn't find anything and
only loops through the first FORM elements.

I'm doing:
Dim wbrElm As mshtml.IHTMLElement

' Create a few variables to hold values from the input element - you
can create more
Dim strName As String
Dim strId As String
Dim strValue As String
Dim strType As String

Try
' Iterate through the collection of html elements, i.e. our
input collection
For Each wbrElm In wbrAll
' Assign the inner html values of the input to our variables
strName = wbrElm.getAttribute("name")
strId = wbrElm.id
strValue = wbrElm.innerText
strType = wbrElm.getAttribute("type")

If (strName <> Nothing) AndAlso ((strName.ToString.ToLower =
"submit1") And (strType.ToString.ToLower = "submit"))

Nothing is ever found on the above. I suppose the DOM for this doc is
structed so that I must first access a specific FORM in the array of forms.
Using some type of dot notation, I probably can access that FORM's elements.
Any ideas?

Thanks,
Brett
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.