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

150
Views
¿Por qué una nueva entrada sobrescribe la anterior?

Quiero guardar el objeto de tareas pendientes con sus propiedades en una matriz, pero si agrego una tarea nueva, sobrescribe la anterior. No puedo pensar en ningún posible problema, el código me parece correcto.

 let head = document.getElementById('txtBox') let date = document.getElementById('date') let description = document.getElementById('description') let todoId = 0 // all Todos const allTodos = { list: [] } // to save inputs let todo = { "name": "", "description": " ", "date": " ", "done": false, "id": 0 } 

 let head = document.getElementById('txtBox') let date = document.getElementById('date') let description = document.getElementById('description') let todoId = 0 // all Todos const allTodos = { list: [] } // to save inputs let todo = { "name": "", "description": " ", "date": " ", "done": false, "id": 0 } function getInput() { todoId++ setInput(head.value, date.value, description.value, todo.id) resetInputFields() } // put input in array function setInput(head, description, date) { //no input without headline if (head) { todoId++ todo.name = head todo.description = description todo.date = date todo.id = todoId; // push input into objet array allTodos.list.push(todo) console.log(allTodos); } else { console.log("Please enter a name"); } } // reset userInput function resetInputFields() { head.value = "" date.value = "" description.value = "" } //reset Object function resetTodo() { todo.name = "" todo.description = "" todo.date = "" }
 <center> <input type="text" id="txtBox"><br> <input type="date" name="" id="date"><br> <textarea id="description" cols="30" rows="10"></textarea> <div id="add" onclick="getInput()" style="cursor: pointer;">add</div> <div id="task"></div> </center>

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!