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

116
Views
for loop con una matriz de cadenas que representan lo mismo dos veces?

Estoy creando en javascript un comentario simple que tiene un área de texto y está agarrando el texto y mostrando un mensaje exitoso cuando se hace clic en el botón Agregar. Cuando se hace clic en el botón Ver comentarios, debería generar los comentarios y lo hace, pero si hago clic en el botón una vez y luego escribo en el área de texto una y otra vez, sigue mostrando varias veces el mismo mensaje de comentarios. Adjunto está mi código javascript.

 var array = Array(); var x = 0; function addFeedback() { array[x] = document.getElementById('feedback').value; x++; document.getElementById('feedback').value = ''; document.getElementById('result').innerHTML = '<h2><h3> Your have successfully Added Feedback!</h3></h2>'; } var feedback = ''; function displayFeedback() { for (var i = 1; i < array.length + 1; i++) { feedback = array[i - 1] + '<br/>'; console.log(feedback); } document.getElementById('result').innerHTML = '<h2>feedback Details: </h2>' + feedback.split('<br>'); }
 <html> <head> <script src="script.js" type="text/javascript"> </script> </head> <body> <!-- Fill code here --> <div> <h2>Feedback for the ART OF LIVING</h2> <div> <label for="feedback"></label>Enter the Feedback: <textarea id="feedback" name="feedback" value="feedback" type="text"></textarea> <div> <input type="button" id="create" name="create" onclick="javascript:addFeedback()">Add Feedback</input><br/> <input type="button" id="view" name="view" onclick="javascript:displayFeedback()">View feedback</input> </div> <div id="result"></div> </div> </div> </body> </html>

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!