I need the for / while to display on the screen the string placed in the input of the first div the first time the loop is executed and the second time it shows on the screen the string placed in the input of the second div and so on. >
<!DOCTYPE html>
<html>
<body>
<div id="cki11" class="ind">
<input class="in" id="in1" placeholder="Nome do indicado">
</div>
<div id="cki12" class="ind">
<input class="in" id="in1" placeholder="Nome do indicado">
</div>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var i = 1;
var x = 2;
var a = 5;
var e = 5;
while(i <= x){
a = "cki1" + i.toString(); // armazena a string correspondente ao id da div que sera chamada
e = document.getElementById(a).children[0].value; // pega o valor do input com base no div pai
document.write(e+"<br>");// exibe o valor do input
i++;
}
}
</script>
</body>
</html>