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

164
Views
its possible to call java script array sort of data on by one after click button

im very confused , to explain my problem and I have searched in various posts in here, but I can't find the solution I'm facing . so i want to ask, its possible to call an array sort of data in java script one by one after the button is clicked ? explain I have a script random like this

$(document).on("click", "#okok", function() {

  var myArray = [
    "5",
    "8",
    "7",
    "2"
  ];

  var randomItem = myArray[Math.floor(Math.random() * myArray.length)];
  var nilai = document.getElementById("pr");

  nilai.value = randomItem;

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<textarea name="pr" id="pr"></textarea>
<br>
<input type="button" id="okok" value="Start">

the script above displays array data one by one but random and not sort.. so i want the display data sort and not random like 2 , 5 ,7 ,8

thanks

about 4 years ago · Juan Pablo Isaza
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!