What you are asking for is incorrectly wrong, it is recommended that the identifiers be unqiue, but for students here, what would you do.
var elem = document.getElementsByTagName("input"); var names = []; for (var i = 0; i < elem.length; ++i) { if (typeof elem[i].attributes.id !== "undefined") { if (elem[i].attributes.id.value == "webcampics") { names.push(elem[i].value); } } } var webcamval = names;
Due to the fact that someone missed the vote, giving a full explanation of why the above method is wrong, but does exactly what you asked for, the correct method is here.
change all id entries to class
var elem = document.getElementsByClassName("webcampics"); var names = []; for (var i = 0; i < elem.length; ++i) { if (typeof elem[i].value !== "undefined") { names.push(elem[i].value); } } } var webcamval = names;
source share