Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!