JavaScript get index of element selected by Document.getElementByID(“id_name”)

For a page ("Bill4Time"), the Dashboard shows a table for displaying time entries and entering a new time entry but several control elements do not have ID's associated with them. Interestingly enough, the control to add a new time entry line (an icon of a clipboard with a small plus sign in the lower right hand corner) always has the same index number (so I can select it with Document.all("index_no") to add a new time entry. But once you edit that line by entering a new time entry, the control icon changes (to a generic clipboard, like all the other time entries in the table) and the index becomes dynamic -- and there is no id associated with that control. However, I found that the parent element (i.e., the table cell) does have a unique ID which never changes (while it is the most recently added time entry) so currently I go to it (using Document.getElementByID("unique_id").focus()) and then send a {tab} to move over to the control element (and send {enter} to go to the correct details page).

If I could get the index number of the unique_id element, and increment that by one, I could more reliably get to the control I want, so my question is, if one has gotten a DOM element by id, how can one find its index number?

When I search here (or google) I get a lot of results for finding the index of the included elements within the parent, or results based on .selectedIndex and the like, and I suppose I could loop through all the DOM elements until I find the one with ID = unique_id, but there should be a better way to get an index number of a selected element.

TIA,

Answer:1

At least if doing it with IE and AutoHotkey this will give you the index

index := wb.document.getElementByID("unique_id").sourceIndex

But you don't need the index if you have the parent element

element := wb.document.getElementByID("unique_id").childnodes[0]

Also a lot of times elements that don't have an ID often have a Name or Class attribute, both of them can also be used to find the element you need...

Answer:2

We'd like to have two outputs from Webpack - our entire app with all of its dependencies, and a single different page with only one dependency (that isn't shared by the main app). It seems the way ...

We'd like to have two outputs from Webpack - our entire app with all of its dependencies, and a single different page with only one dependency (that isn't shared by the main app). It seems the way ...

  1. multiple entries webpack
  2. multiple entry webpack 4
  3. multi entry webpack
  4. multiple webpack entry points
  5. multiple entry files webpack
  6. multiple entry output webpack
  7. multiple entry points webpack 4
  8. multiple entry points webpack-dev-server
  9. multiple entry points webpack config
  10. webpack multiple entries one output
  11. webpack multiple entries not working

I have a search box which should work with pressing the button and also pressing the Enter key. They both have the same code. The button works perfectly but when it comes to the Enter key, most of the ...

I have a search box which should work with pressing the button and also pressing the Enter key. They both have the same code. The button works perfectly but when it comes to the Enter key, most of the ...

I'm trying to do something I don't remember/find if it is possible in javascript. I have an object constructor "Point" and I want to know if it possible to, for example, sum two different objects ...

I'm trying to do something I don't remember/find if it is possible in javascript. I have an object constructor "Point" and I want to know if it possible to, for example, sum two different objects ...

  1. properties object javascript
  2. object properties javascript loop
  3. object properties javascript class
  4. merge properties objects javascript
  5. add properties objects javascript
  6. properties inside objects javascript
  7. get properties object javascript
  8. iterate properties object javascript
  9. count properties object javascript
  10. delete properties object javascript
  11. list properties object javascript
  12. remove properties object javascript
  13. show properties object javascript
  14. filter properties object javascript
  15. foreach properties object javascript
  16. compare properties object javascript
  17. check properties object javascript
  18. copy properties object javascript
  19. update properties object javascript
  20. print properties object javascript

I'm trying to start a git repo when scaffolding an application with a yeoman custom generator, this is what I got at the install step: install: function () { this.installDependencies(); ...

I'm trying to start a git repo when scaffolding an application with a yeoman custom generator, this is what I got at the install step: install: function () { this.installDependencies(); ...

  1. handling error events