I have accessed a table on a webpage, and I know I can navigate to the right cell on it because I can read the inner text to get the correct value. But I need to care about the class of the cell i'm looking at. Psudo code to follow.
<tr id="row1887">
<td align="center" class="emergency"><div class="txt02" id="available.qty1887">50 </div></td>
<td width="32px" align="center" class="bodyrowborder"><div class="txt02">1887</div></td>
<td width="65px" align="left" class="bodyrowborder" ><div class="txt02"> Name</div></td>
</tr>
I need to be able to tell when a cell has the "emergency" class. I've tried CurrentRow.cells[0].class and other varriations on that level of access, where CurrentRow.cells[0].innerText will give me 50.
Any tips to get me into the right direction would be appreciated.
Getting class of html cell
Re: Getting class of html cell
Does this work?
CurrentRow.cells[0].className
CurrentRow.cells[0].className
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Getting class of html cell
You can also use classList to get a sort of array and see if the array contains your value you are checking for, in case they have multiple classes. See https://www.w3schools.com/jsref/prop_el ... sslist.asp
Re: Getting class of html cell
Do either of you have any handy code or advice for getting information from tables?
E.g. to grab all the text from a column or table (perhaps tab-separated).
List of countries and dependencies by population - Wikipedia
https://en.wikipedia.org/wiki/List_of_c ... population
Variables and Expressions
https://autohotkey.com/docs/Variables.htm#BuiltIn
Ask For Help - AutoHotkey Community
https://autohotkey.com/boards/viewforum ... rum-search
E.g. you could click to set the active element, or to get the element under the cursor:
Internet Explorer get element under cursor (show borders, show text) (any zoom percentage) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=29458
But I'm not familiar with handling tables. Cheers.
Btw in Firefox, you can do ctrl+drag to select cells in a table.
[EDIT:] I have since found a good way to get text from html tables:
webpages: get table text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=39131
E.g. to grab all the text from a column or table (perhaps tab-separated).
List of countries and dependencies by population - Wikipedia
https://en.wikipedia.org/wiki/List_of_c ... population
Variables and Expressions
https://autohotkey.com/docs/Variables.htm#BuiltIn
Ask For Help - AutoHotkey Community
https://autohotkey.com/boards/viewforum ... rum-search
E.g. you could click to set the active element, or to get the element under the cursor:
Internet Explorer get element under cursor (show borders, show text) (any zoom percentage) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=29458
But I'm not familiar with handling tables. Cheers.
Btw in Firefox, you can do ctrl+drag to select cells in a table.
[EDIT:] I have since found a good way to get text from html tables:
webpages: get table text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=39131
Last edited by jeeswg on 29 Oct 2017, 12:52, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Getting class of html cell
First isolate the table, then make a list of rows (every tr) and for each for that a list of every column/cell (td) in addition.
Use
Code: Select all
[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
Re: Getting class of html cell
currentrow.cells[0].classname Does not work. Unfortunately.
I'll give the class list and getting the td of the cells.
As a side thought do you know if I can getElementByTag on my object that is holding my table rows?
I'll give the class list and getting the td of the cells.
As a side thought do you know if I can getElementByTag on my object that is holding my table rows?
Re: Getting class of html cell
[Solved]
CurrentRow.cells[0].class doesn't work because it was the wrong element call.
CurrentRow.cells[0].className correctly returns the cells class.
Thanks for all the help all.
CurrentRow.cells[0].class doesn't work because it was the wrong element call.
CurrentRow.cells[0].className correctly returns the cells class.
Thanks for all the help all.