You should not ask a question here that concerns a script with an active "On Error
Resume Next". That is a waste of everybody's time. By not hiding errors/Pay attention to
error messages, you can solve the problem(s) on your own (most of the time).
Delete/Deactive the OERN and you get
set val =ie.document.getElementsById("test").item(1).value
==>
... runtime error: Object doesn't support this property or method: 'ie.document.getElementsById'
Even if you don't recognize the typo, a google search for "html dom getelementsbyid"
will re-route you to "Ergebnisse für [i.e. results for] html dom getelementbyid".
Follow one of the first links (e.g.) to refresh you knowledge about that method.
That way the next error:
set val =ie.document.getElementById("test").item(1).value
==>
... runtime error: Object doesn't support this property or method: 'ie.document.getElementById(...).item'
won't surprise you. An element isn't a collection of items/elements. [BTW: You shouldn't
post answers here without at least basic tests].
The next version
set val =ie.document.getElementById("test").value
should raise a red alert: An assignment with Set, but a right value that wants to be a
property of an object. That is blantantly wrong. So try:
set elm =ie.document.getElementById("test") ' at least a decent assignment
val = elm.value
==>
... runtime error: Object doesn't support this property or method: 'elm.value'
A google query like "html dom div text" will point you to "innerText"
and its features: 1 or 2
At last:
set elm =ie.document.getElementById("test") ' at least a decent assignment
val = elm.innerText
success!
cscript 23971918.vbs
value is= 24