Accessing a Textarea that Does Not Have an ID

Still working on my project, and actually getting some decent results, and I came across in issue.

The main edit window in phpBB has an ID assigned:

<div id="message-box" class="message-box">
     <textarea name="message" id="message" rows="15" cols="76" tabindex="4" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();" class="inputbox" style="position: relative;"></textarea>
</div>

But the quick reply text box at the end of each discussion page does not:

<div id="message-box" class="message-box">
      <textarea style="height: 9em;" name="message" rows="7" cols="76" tabindex="3" class="inputbox"></textarea>
</div>

This means that the code that I use to access the contents of the text box throws an error, TypeError: document.getElementById(...) is null, on the latter form of the box.

This means that I cannot extract the data from the 2nd text box that I need, because it is dependent on the id of an element that does not have an id:

let TextBoxID = clickedElement.getAttribute('id');
let FocusInfo = document.activeElement;
let txtcont = document.getElementById(TextBoxID).value; //contents of edit box
let selstart = clickedElement.selectionStart; // index of selectin start
let selend = clickedElement.selectionEnd; //index of selection end
let selcont = txtcont.substring(selstart,selend); // selected text content
let firsttext = txtcont.substring(0,selstart); //stuff before the selection
let lasttext = txtcont.substring(selend); // stuff after the selection

Is there an ID hiding somewhere, or can I assign an id to the object on the page if it does not have one?

You get the .id of the element just so you can find the same element by its .id.
Why aren’t you just you using the element straight away?

let txtcont = clickedElement.value

D’oh!

I am an imbecile.