Open In App

How to Build a To Do App With ChatGPT?

Last Updated : 05 Jun, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

In the year 2023, it is very easy to build a TO-DO app with the help of ChatGPT. In this article, we will make a TODO app with ChatGPT. The TODO app is generally used to track our daily goals and the work we need to do on a daily basis. We can organize our tasks based on our requirements. TO-DO app can be used to schedules daily. At any point in time, we can Create, Edit, Read, and Delete our tasks from the TO-DO app. 

How to Build a To Do App With ChatGPT

Let's see one basic prompt that we can give for How to build a TODO app with ChatGPT:

I want you to write code for a to-do list web app using HTML, CSS, and JavaScript. It should contain basic functionalities like Create, Edit, Read, and Delete tasks. Also, try to style the page as much as possible.

ChatGPT-To-Do-App-Prompt

Now, you just need to copy the code generated by ChatGPT and paste it into your Code Editor in an HTML file. Below is the code generated by ChatGPT:

HTML
<!DOCTYPE html>
<html>
<head>
  <title>TO DO List</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f2f2f2;
    }
    
    .container {
      max-width: 400px;
      margin: 0 auto;
      padding: 20px;
      background-color: #fff;
      box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    }
    
    .header {
      text-align: center;
      margin-bottom: 20px;
    }
    
    .task-input {
      width: 100%;
      padding: 10px;
      margin-bottom: 10px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    
    .task-list {
      list-style-type: none;
      padding: 0;
    }
    
    .task-list li {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px;
      background-color: #f2f2f2;
      border-radius: 4px;
      margin-bottom: 5px;
    }
    
    .task-list li .task {
      flex-grow: 1;
    }
    
    .task-list li .edit-btn,
    .task-list li .delete-btn {
      background-color: #4286f4;
      color: #fff;
      border: none;
      padding: 5px 10px;
      border-radius: 4px;
      cursor: pointer;
    }
    
    .task-list li .edit-btn {
      margin-right: 5px;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="header">
      <h1>TO DO List</h1>
    </div>
    
    <input id="task-input" class="task-input" type="text" placeholder="Enter a task">
    <button id="add-btn">Add Task</button>
    <ul id="task-list" class="task-list"></ul>
  </div>

  <script>
    // Get elements
    const taskInput = document.getElementById('task-input');
    const addBtn = document.getElementById('add-btn');
    const taskList = document.getElementById('task-list');

    // Add task function
    function addTask() {
      const task = taskInput.value;
      if (task.trim() === '') return;

      const li = document.createElement('li');
      li.innerHTML = `
        <span class="task">${task}</span>
        <button class="edit-btn">Edit</button>
        <button class="delete-btn">Delete</button>
      `;

      taskList.appendChild(li);
      taskInput.value = '';
    }

    // Edit task function
    function editTask(e) {
      const taskSpan = e.target.previousElementSibling;
      const newTask = prompt('Edit task:', taskSpan.innerText);

      if (newTask && newTask.trim() !== '') {
        taskSpan.innerText = newTask;
      }
    }

    // Delete task function
    function deleteTask(e) {
      if (e.target.classList.contains('delete-btn')) {
        e.target.parentElement.remove();
      }
    }

    // Event listeners
    addBtn.addEventListener('click', addTask);

    taskList.addEventListener('click', function (e) {
      if (e.target.classList.contains('edit-btn')) {
        editTask(e);
      } else if (e.target.classList.contains('delete-btn')) {
        deleteTask(e);
      }
    });
  </script>
</body>
</html>

Below is the Output Generated by the above HTML file. Now, Based on your creativity, you can ask ChatGPT to generate code or modify the existing code by directing ChatGPT.

ChatGPT To Do App HTML CSS

Conclusion

In Conclusion, building a TO-DO web app with the help of ChatGPT has become very easy for developers. This article provided a step by step approach to how to create a TO-DO app with the help of ChatGPT using HTML, CSS, and JavaScript. This app allows users to Create, Delete, Edit, and Modify daily goals. However, the above article was more focused on the Frontend part and it does not include the backend of the web application. But with the help of ChatGPT, we can also create a backend for the above web application.


Next Article

Similar Reads