What do I do when running a function in javascript, does it cause the previous function to go back to the beginning, not accepting the changes made?
<html>
<script>
function criartabela() {
n = document.getElementById("ordem").value;
a = n * n;
for (i = 1; i <= a; i++) {
valor = '' + i;
conteudo = '<input type="number" id=' + valor + ' value="3"/>';
}
var html = "";
html += '<table border>';
for (var x = 1; x <= n; x++) {
html += '<tr>';
for (var y = 1; y <= n; y++) {
html += '<td>' + conteudo + '</td>';
}
html += '</tr>';
}
html += '</table>';
document.getElementById('diiiv').innerHTML = html;
}
function matriz() {
criartabela();
termo = [];
m = '';
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
b = document.getElementById("" + valor + "").value;
termo[i] = '\r\nA' + i + '' + j + '\r\n=' + b + '<br>';
m = m + termo[i];
}
}
document.getElementById("matriz").innerHTML = m;
}
</script>
<body>
<blockquote><blockquote> <!-- 2 tabs -->
<form>
<br><br>
Ordem da Matriz Quadrada:
<input type="number" id="ordem" value=" ">
<br><br>
</form>
<button onclick="criartabela()">Gerar Matriz a ser Preechida</button>
<br><br>
<style>ins{text-decoration:none;}</style>
<ins id="diiiv"></ins>
<br><br>
<button onclick="matriz()"> Valores dos termos </button>
<br><br>
<style>ins{text-decoration:none;}</style>
<ins id="matriz"></ins>
<br><br>
</blockquote></blockquote>
</body>
</html>