Question

In: Computer Science

For this assignment you need to create a ToDo list using Javascript, along with HTML and...

For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS.

Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link in CSS from a separate file).

On the todo.html page, create two blocks of content (see the attached diagram).

At the top of the page, create a HTML form with the label New Item.

  • The form should contain two elements: a textarea and a submit button.
  • The submit button should be disabled if there is no text in the textarea. Inputting text in the textarea should enable the button.
  • If the submit button is clicked while enabled, a new item should be added to the Item List section below the form. Once the item is added, the textarea should be cleared.

Below the form, create a block with the label Item List. This block will initially be empty.

When the submit button in the form is clicked, a new sub-block of content ('item block') should be created containing the following:

  • The text from the textarea in the form.
  • A timestamp below the text. This timestamp should be in a user-friendly format showing date and time (down to minute) that the item was created. This should be auto-generated based on the computer's local time.
  • A delete button in the upper right of the item block, floated to the right of the text. When the delete button is clicked, the entire item block should be deleted. (You can include an 'Are you sure' confirm dialog if you like.)

Additional item blocks should be appended after the first item in the list. Item blocks should stack vertically.

<!DOCTYPE html>
<html>
<head>
   <title>TODO List</title>
   <script src="todo.js"></script>
   <style>
   #secondBlock{          
       color : black;
       visibility : hidden;
       width : 500px;
       height : 50px;  
   }
   button{
       width : 150px;
       height : 30px;
       border-radius : 5px;
       background-color : cyan;
       color : black;
   }  
   </style>
</head>
<body>
   <h1>TODO LIST : </h1>
   <form>
       <label>New Item</label></br>
       <TextArea rows="5" cols="20" id="itemTxt" onkeypress="textTyped()"></TextArea>
       <br/><br/>
       <button onclick="return addItem()" id="submit" disabled>Submit</button>
   </form>
   <div id="secondBlock">
      
   </div>
</body>

function textTyped(){
   var inputText = document.getElementById("itemTxt").value;
   var submitBtn = document.getElementById("submit");  
   if(inputText.length == 0) {
       submitBtn.disabled = true;
   }else {
       submitBtn.disabled = false;
   }
}
function addItem() {  
   var inputText = document.getElementById("itemTxt");  
   var submitBtn = document.getElementById("submit");  
   var nextBlock = document.getElementById("secondBlock");  
   var newPara = document.createElement("p");  
   var date = new Date();
   newPara.innerHTML = inputText.value + "<br>" + date.getDate() + "/" + (parseInt(date.getMonth())+1) + "/" + date.getFullYear() + " "
   + date.getHours() + ":" + (date.getMinutes()-1) + ":" + date.getSeconds();  
   var deleteBtn = document.createElement("BUTTON");
   deleteBtn.innerHTML = "DELETE ITEM";
   deleteBtn.onclick = function() {
       newPara.remove();
   }
   newPara.style.width = "500px";
   deleteBtn.style.cssFloat = "right";  
   newPara.appendChild(deleteBtn);
   nextBlock.appendChild(newPara);      
   nextBlock.style.visibility = "visible";  
   inputText.value = "";
   submitBtn.disabled = true;
   return false;
}
</html>

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

todo.js

function textTyped(){
  var inputText = document.getElementById("itemTxt").value;
  var submitBtn = document.getElementById("submit");  
  if(inputText.length == 0) {
      submitBtn.disabled = true;
  }else {
      submitBtn.disabled = false;
  }
}
function addItem() {  
  var inputText = document.getElementById("itemTxt");  
  var submitBtn = document.getElementById("submit");  
  var nextBlock = document.getElementById("secondBlock");  
  var newPara = document.createElement("p");  
  var date = new Date();
  newPara.innerHTML = inputText.value + "<br>" + date.getDate() + "/" + (parseInt(date.getMonth())+1) + "/" + date.getFullYear() + " "
  + date.getHours() + ":" + (date.getMinutes()-1) + ":" + date.getSeconds();  
  var deleteBtn = document.createElement("BUTTON");
  deleteBtn.innerHTML = "DELETE ITEM";
  deleteBtn.onclick = function() {
      newPara.remove();
  }
  newPara.style.width = "500px";
  deleteBtn.style.cssFloat = "right";  
  newPara.appendChild(deleteBtn);
  nextBlock.appendChild(newPara);      
  nextBlock.style.visibility = "visible";  
  inputText.value = "";
  submitBtn.disabled = true;
  return false;
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

index.html

<!DOCTYPE html>
<html>
<head>
   <title>TODO List</title>
   <script src="todo.js"></script>
   <style>
   #secondBlock{          
       color : black;
       visibility : hidden;
       width : 500px;
       height : 50px;  
   }
   button{
       width : 150px;
       height : 30px;
       border-radius : 5px;
       background-color : cyan;
       color : black;
   }  
   </style>
</head>
<body>
   <h1>TODO LIST : </h1>
   <form>
       <label>New Item</label></br>
       <TextArea rows="5" cols="20" id="itemTxt" onkeypress="textTyped()"></TextArea>
       <br/><br/>
       <button onclick="return addItem()" id="submit" disabled>Submit</button>
   </form>
   <div id="secondBlock">
      
   </div>
</body>
</html>

Related Solutions

For this assignment you need to create a ToDo list using Javascript, along with HTML and...
For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link in CSS from a...
For this assignment, you will write a tic-tac-toe application in HTML and JavaScript, using an HTML...
For this assignment, you will write a tic-tac-toe application in HTML and JavaScript, using an HTML <canvas> tag. The game will be played "hot seat" where players take turns using the same device. Requirements: The canvas should be 600px tall and wide, with the gameplay area occupying most of the canvas. The X's and O's may be drawn using polygons or large-font text The grid should be drawn using polygons, specifically long, thin rectangles Before & between games, the canvas...
The code to create a Search/Filter Data with Javascript or html from html page.
The code to create a Search/Filter Data with Javascript or html from html page.
Please Use JavaScript and HTML 5) Number guesser (easier) Create a number guessing name, using an...
Please Use JavaScript and HTML 5) Number guesser (easier) Create a number guessing name, using an input and a button to gather a number. The number to be guessed should be a hard-coded whole number between 1 and 20. Tell the user if the number is too high, equal to, or too low than a number you have hard-coded in your application. Remove the text in the input when the user clicks the button.
This assignment is about using attributes in HTML. The attributes you will use for this assignment...
This assignment is about using attributes in HTML. The attributes you will use for this assignment include the lang attribute, the type attribute, and the start attribute. For this assignment, you will write an HTML document to create a web page that contains ordered lists with numbers, uppercase letters, lowercase letters, uppercase Roman numerals, and lowercase Roman numerals; and a list with lowercase Roman numerals that starts at a value other than 1. Your document can be about any topic...
**Need HTML and Javacript** You will need to fork your JSFiddle for your List into a...
**Need HTML and Javacript** You will need to fork your JSFiddle for your List into a new Fiddle. In this Fiddle we are going to add sorting functions. This is a great time to clean up your list with things that you have learned. You should automatically populate the List with 20 element (random strings). Once you have completed this – you will add 2 sort functions, you can use any sort method that you desire for each of the...
Assignment: The Ordered List In this assignment, you will create an ordered list of movies. The...
Assignment: The Ordered List In this assignment, you will create an ordered list of movies. The list will always be maintained in sorted order (ascending order, by movie title) by assuring that all new movies are inserted in the correct location in the list. Create a new project to hold your implementation of an ordered singly-linked list. You will need a main.cppto use as a test driver, as well as header and implementation files as described below. Movie To represent...
Build an application using HTML, CSS, javascript, json. It is not necessary for backend to be...
Build an application using HTML, CSS, javascript, json. It is not necessary for backend to be working but the frontend should be good. App should to simple and useful in our day to day life. For eg- grocery shopping list or alarm or weather forecast or reminder.
Create a web page using PHP and HTML that contains a list of movie names available...
Create a web page using PHP and HTML that contains a list of movie names available for rent (at least 10 movies), so that each time you visit the home page, you see a different order of movies in the list. The movie names are required. 2) The rental price for each movie ranges between $1.99 to $7.99. • Create an associative array with a code for the movie as the key (e.g., movie1, movie2, etc.) and the associated rental...
JavaScript (HTML) Task: Please read 10 numbers that are list below, sort the numbers and then...
JavaScript (HTML) Task: Please read 10 numbers that are list below, sort the numbers and then print those numbers. 10 numbers = { 9, 3, 2, 1, 10, 30, 4, 6, 7, 8} [Reference JavaScript code] <html> <body>     <H1>prompt()</h1>     <p id="pro"></p>     <script>        // Array creation        var num= new Array();               var ix = 0;        // Read 10 numbers        for (ix = 0; ix < 10; ix++)        {num[ix] = prompt("Enter a number");...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT