One Function interferes with another

0

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>
    
asked by anonymous 10.07.2015 / 21:19

1 answer

0

I understand that you want something like this:

function anterior(acao)
{

var data = 'inicio';

if (!executora(acao)) {
   for (var i=0; i<=20; i++) {
     if (i==0) {
         data='';
     }
         data += 'executou '+i+"\n";
   }
 data +='fim';
}
return data;
}

function executora(acao) 
{
 return acao;
}

var saia_anterior = anterior(true);
var saida_posterior = anterior(false);

console.log(saia_anterior+'=======>'+saida_posterior);
    
10.07.2015 / 21:50