Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
When i created a input box, how can i make it so it outputs how much I put into the input box?

Im having trouble making this work and I cant find the loose end. Im trying to make it so when I put a certain amount of rolls in, it outputs as that many rolls and records the data. But when I click the button, nothing happens.

<html>
    <head>
        <meta charset="utf-8" />
        <title>Rollstats</title>
        <script src="http://compsciconcepts.com/random.js"></script>
        <script>
            function Roll() {
                roll1 = RandomInt(1, 6);
                roll2 = RandomInt(1, 6);

                if (roll1 == roll2) {
                    doubleSpan.innerHTML = Number(doubleSpan.innerHTML) + 1;
                } else if (roll1 + roll2 == 7) {
                    sevenSpan.innerHTML = Number(sevenSpan.innerHTML) + 1;
                    if (roll1 == 3 || roll1 == 4) {
                        naturalSpan.innerHTML = Number(naturalSpan.innerHTML) + 1;
                    }
                }
            }

            function ResetCounts() {
                doubleSpan.innerHTML = 0;
                sevenSpan.innerHTML = 0;
                naturalSpan.innerHTML = 0;
            }
        </script>
    </head>
    <body style="text-align: center">
        <h1>Dice Simulations</h1>
        <p>
            Desired number of rolls:
            <input type="number" id="desiredBox" min="0" max="9999999" value="1000" />
            <button onclick="Roll();">Click to Roll</button>
            <button onclick="ResetCounts();">Reset Counts</button>
        </p>
        <hr />
        <p>Number of doubles: <span id="doubleSpan">0</span></p>
        <p>Number of sevens: <span id="sevenSpan">0</span></p>
        <p>Number of Natural sevens:<span id="naturalSpan">0</span></p>
    </body>
</html>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you can't just call doubleSpan.innerHTML you need to get the element first:

doubleSpan = document.getElementById('doubleSpan');
doubleSpan.innerHTML = "..."
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda