document.getElementById(`name${i}`).value code example Example: getelementbyid document.getElementById("someid");