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

134
Views
¿Hay alguna forma de imprimir el contenido de una matriz en un área de texto?

Obtuve un script que elige una palabra aleatoria de una matriz. Lo que quiero que haga es imprimir una de estas matrices en un área de texto después de que el usuario haga clic en un botón.

 <!DOCTYPE html> <html> <head> </head> <body> <script> var myArray = [ "Test", "Work", "Life" ]; var randomItem = myArray[Math.floor(Math.random()*myArray.length)]; document.body.innerHTML = randomItem; </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede seleccionar su área de texto con algunos métodos de JavaScript como document.getElementById , document.querySelector y establecer su valor.

 const myArray = ["Test", "Work", "Life"]; // const textArea = document.getElementById('my-textarea'); const textArea = document.querySelector('#my-textarea'); function updateTextArea() { var randomItem = myArray[Math.floor(Math.random() * myArray.length)]; textArea.value = randomItem; }
 <textarea name="" id="my-textarea" cols="30" rows="10"></textarea> </br> <button onclick="updateTextArea()">Update Textarea</button>

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!