Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does document.getElementsByTagName work in vbscript?

Tags:

html

vbscript

Well, it works, it just doesn't produce anything worthwhile:

elems = document.getElementById("itemsTable").getElementsByTagName("TR") 
for j = 0 to ubound(elems) - 1      
   ' stuff 
next

Well, that won't work, apparently elems is an object, not an array like you'd get in that fancy javascript. I'm stuck with vbscript though.

So what do I do to iterate all the rows in a table in vbscript?

Edit: Yes, it's vbscript and it sucks. I don't have a choice here, so don't say "Use jQuery!!".

like image 363
jcollum Avatar asked Feb 28 '23 06:02

jcollum


1 Answers

As you have correctly stated getElementsByTagName does not return an array, hence UBound() will not work on it. Treat it as a collection.

For-Eaching through it should work:

 Set NodeList = document.getElementById("itemsTable").getElementsByTagName("TR") 
 For Each Elem In NodeList
  ' stuff 
  MsgBox Elem.innerHTML
 Next
like image 146
Yannick Motton Avatar answered Mar 06 '23 23:03

Yannick Motton