I have a function that prints a list from an array. I want the user to be able to select multiple different items in the array by using a checkbox next to them. How would I display a checkbox next to each array element? (Currently learning JS)
function par() {
var courses = ["SDEV", "DBMS","INFM", "CSCI", "SVAD", "NETI", "ITSP", "CSIA"];
var text = "";
var i;
for (i = 0; i < courses.length; i++) {
text += courses[i] + "<br>";
}
document.getElementById("demo").innerHTML = text;
}
text += "<input type='checkbox' data-index='" + i + "'/>" + courses[i] + "<br>";! Thedata-indexattribute will have the index of the item from the array!