0
Can you help me with a code?
I need you to enter information in two Array
through two different messages prompt
whenever the "Add Account" button is triggered and, as soon as the "Show Accounts" button is triggered, show all accounts in a table with the account number (nCad), name and value in the account. My code doesn’t work the way I’d like it to.
var nomeA = new array[''];
var account = new array[''];
var nCad = new array[''];
var cadastro = 0;
function addAccount(){
cadastro++;
nomeA.push = prompt("Nome: ");
account.push = prompt("Conta: ");
nCad.push = cadastro;
}
function showAccounts(){
info.innerHTML("<table>");
for(x=0; x=cadastro; x++){
info.innerHTML("<tr>");
info.innerHTML("<td>" + nCad[x] + "</td>");
info.innerHTML("<td>" + nomeA[x] + "</td>");
info.innerHTML("<td>" + account[x] + "</td>");
info.innerHTML("</tr>");
info.innerHTML("</table>");
}
td{
border: 1px solid grey;
}
<button onclick="addAccount()">Adicionar Conta</button>
<button onclick="showAccounts()">Mostrar Contas</button>
<div id="info"></div>
Hi Gabriel, one is missing
}
in functionshowAccounts
. You know it or that’s your problem?– Sergio