I want the user to enter the row and column quantity of a table and display its values in the table. But when typing the number of rows and columns in the prompt does not display the table and values.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Untitled Document</title>
<style>
.verde{
background-color: green;
}
.amarelo{
background-color: yellow;
}
</style>
<script>
function criaTabela(linha,coluna){
conteudo="";
conteudo += "<table border='1'>";
for (i=1;i<=linha;i++){
conteudo += "<tr>";
for (j=1; j<=coluna;j++){
if(j % 2 == 0) {
conteudo += "<div class='coluna_verde'><td>"+ i +" " + j +"</td></div>";
}
else{
conteudo += "<div class='coluna_amarelo'><td>"+ i +" " + j +"</td></div>";
}
}
conteudo += "</tr>";
}
conteudo += "</table>";
document.getElementById("tab").innerHTML=conteudo;
}
window.onload=function(){
do{
var linha= prompt("Digite a quantidade de linha");
var coluna= prompt("Digite a quantidade de coluna");
criaTabela(linha,coluna);
}while (linha != null && coluna !=null );
console.log("linha"+linha);
console.log("coluna"+coluna);
}
</script>
</head>
<body>
<div id="tab"></div>
</body>
</html>