0
I am trying to add the names to count a number which have been created, under the title name this number 3 right ? I know number three is because I got the letter number. But how do I do it ?
- Example 1 - yes 2 - yes
let a = []
function botao() {
var nome = document.getElementById("nome")
var r = document.getElementById("res")
if (nome.value == "") {
alert("Por favor digite um nome!")
}
if (nome.value.length) {
a.push(nome)
r.innerHTML += ` <tr><th scope="row">${nome.value.length}</th> <td>${nome.value}</td>`
}
}
<div class="container">
<h1 class="text-center mt-3">
Agenda
</h1>
</div>
<div class="container">
<table class="table">
<thead>
<tr>
<th scope="col">Nome</th>
</tr>
</thead>
<tbody id="res">
</tbody>
</table>
</div>
<div class="text-center">
<h1 class="text-center mt-2 mb-4">Registe por aqui</h1>
<input type="text" id="nome" name="nome" placeholder="NOME">
<input type="submit" id="btn" onclick="botao()">
</div>
Look I read 2x and I can’t understand what you want to do
– Ricardo Pontual
Calm down, you saw in the image below the name has a number (3) right? I want to do type first that was created called (1-Ricardo) second time (2 - Julio) understood? but in the image that this (3 - yes)
– Julio S