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

136
Visualizações
Pushing input into a array

For the most part, i got it all done. But when i refresh the page it does not save into the array and i cant find it, how do i make it so its not just a temp array and keep it in the website. Here is my code

const output = document.getElementById("joke")


var jokes = ["test123", "test1235", "testting 1"]

function inputJoke() {
    boxvalue = document.getElementById('box').value;
    jokes.push(boxvalue);
    console.log(jokes);
    return false;
  }

function randomChoice(){
    return jokes[Math.floor(Math.random() * jokes.length)]
    }

function jokeText(){
    output.innerHTML = `${randomChoice()}`
}

<div class="container">
    <h3>Douglas Dad Joke Generator</h3>
    <br>
    <br>
    <button id="jokeBtn" onclick="jokeText()" class="btn">Get Another Joke</button>
    <div class="text" id="joke"></div>

    <form onsubmit="return inputJoke()">
      <input class="submit" placeholder="Dad joke" type="text" id="box">
      <input class="submit" type="submit" value="Submit">
     </form>

  </div>

  <script src="script.js"></script>
  <link rel="stylesheet" href="style.css">

Here is the website https://dad.sscottdev.com

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

0

As it is, your jokes are stored in the code itself, or as we call it, hardcoded. If you wish for people to input and save their jokes you will have to add a small database and a small backend with it. I suggest you try looking for easy and simple ways for doing that like FastAPI(my recomendation), but in the end all you need is a remote database where all your jokes will be stored and can be retrieved from.

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