[RESOLVED] getelement by class, value within input, td, span, etc.-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] getelement by class, value within input, td, span, etc.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    19

    Resolved [RESOLVED] getelement by class, value within input, td, span, etc.

    There are a couple of websites that have a lot of td's. They don't have names or ids but they do have classes or values. The classname or value is the same for many of the tds. How can I get for example the 5th instance of a classname or value on a web page that is also a td? Something like this maybe:
    range("a2").value = appIE.document.getelementbytagname("td").classname(4).innertext

    I've run across this with span instead of td and value instead of classname too, I'm not sure how to approach 2 layers of sameness like that.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    20,022

    Re: getelement by class, value within input, td, span, etc.

    value instead of classname too
    you can loop through, until you match value but span and class you have to parse the innerhtml and increment a counter until you get to the specific element
    else you can use code similar to the example in your other thread, which matches to value then returns the next td
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: getelement by class, value within input, td, span, etc.

    Loop through the elements, looking for the 5th instance of HTMLTableCell.className = "YourClassName".

  4. #4
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,197

    Re: getelement by class, value within input, td, span, etc.

    is there no other absolute match you can make

    here to guide

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    19

    Re: getelement by class, value within input, td, span, etc.

    For a simpler example, how can I go directly to an element by knowing it is the nth element with a specific classname? Without looping through all of the elements that have the same classname. Like if the classname is "someClass" then something like this: ie.document.someClass(4) or ie.document.getelementsbyclassname("someClass")(4) to access only the 5th one.

    What is the right syntax?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.