I am trying to update the same element that's in another class. So currently the user_friendlist and activeusers are both are arrays of strings and it checks if both arrays contain a same entry. If that's the case then I also want to update the same element so could be [0] or [1] for both different classes.
But I don't know how to do this, I know how to do it for one class but how could I do this for the other class while checking the first one. And that's also the same element as the other one so both element0 for example but then for both different classnames.
//Display if a player is online and if he is also in the players friendlist
let friendOnlineNames = document.getElementsByClassName('friendlistentry')
let friendlistactivitystatus = document.getElementsByClassName('friendlistactivitystatus')
const filteredArray = user_friendlist.filter(value => activeusers.includes(value));
console.log(filteredArray)
let friendNamesToString = filteredArray.toString()
console.log(friendNamesToString)
for (let i = 0; i < friendOnlineNames.length; i++) {
if (friendOnlineNames[i].innerHTML == friendNamesToString) {
friendlistactivitystatus[i].innerHTML = "Online"
}
}
<h4 id="friendlisttext">Friends list
<%= user.friendlist.length%>/20 </h4>
<div id="friendlistblock">
<l class="friendlistentry">
<%=user.friendlist[0]%>
</l>
<br/><br/>
<form method="POST">
<h2 class="friendlistactivitystatus"></h2>
<input class="friendlistentryinput" name="friend0" label="friend0" type="text" value="<%=user.friendlist[0]%>">
<button class="friendlistentrymessagebutton" formaction="friend0message">Send Message</button>
<button class="friendlistentryprofilebutton" formaction="friend0profile">View Profile</button>
</form>
<l class="friendlistentry">
<%=user.friendlist[1]%>
</l> <br/><br/>
<form method="POST">
<h2 class="friendlistactivitystatus"></h2>
<input class="friendlistentryinput" name="friend1" label="friend1" type="text" value="<%=user.friendlist[1]%>">
<button class="friendlistentrymessagebutton" formaction="friend1message">Send Message</button>
<button class="friendlistentryprofilebutton" formaction="friend1profile">View Profile</button>
</form>