PROBLEM: access an HTML element and change its value with visual basic
TWIST: if the element has an unique value for attribute "name", you may think to access directly that element by its name.
I THINK IT'S IMPOSSIBLE.
GetElementByName doesn't work (or doesn't exist at all) : pay attention to the singular "ElementBy"
GetElementsByName works, BUT IT RETURNS A COLLECTION of objects. pay attention to the plural "ElementsBy"
If you use it this way: obj1=GetElementsByName ("name"), it will end in a obj1 that is a collection, and then it has NOT the "value" property or attribute
So, the correct way to access an element by its unique name is this:
1) Loop For to get all elements by tag name
2) If statement to place an action to a single element
Codice: Seleziona tutto
For Each objLink In IE.Document.GetElementsByTagName("input")
If objLink.Name = "nGiust0" Then
objLink.Value = "1"
Exit For
End If
Next objLink
If anyone has a better way, please tell me