I am working on an express app where I need to loop through data in my EJS file to create 5 hidden input fields, each with a unique value.
However, I am struggling to extract the values of these inputs using JavaScript. Despite trying multiple methods, I have not been successful.
Here is a snippet of my code:
HTML:
<% course.content.forEach(function(content, i) { %>
<input class="editCourseContent" type="hidden" value="<%= course.content[i] %>">
<% }); %>
JavaScript:
hiddenInputEdit = document.getElementsByClassName('editCourseContent');
includeEditTags();
function includeEditTags(){
for(var i = 0; i < hiddenInputEdit.length; i++){
alert(hiddenInputEdit[i].value);
}
}