var myPersons__ = document.querySelectorAll('.avtrlnk'); var maxId__ = []; for(var x = 0; x < myPersons__.length; ++x) { maxId__[x] = myPersons__[x].value; } myPersons__ = parseInt(maxId__.sort()[x-1]) + 1;