Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda