todolist.php

<?php include "base.php"; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title> To Do List </title> <script src="js/utility.js" type="text/javascript"></script> <?php if(!empty($_POST['taskdetail'])) { foreach($_POST['taskdetail'] as $taskid) { $sql_cmd = "Delete from tblToDoList where taskid=" .$taskid; $dbh->exec($sql_cmd); } } ?> <noscript> document.write("Please enable JavaScript in your browser to experience all the features."); </noscript> <?php if(!empty($_POST['taskdetail'])) { foreach($_POST['taskdetail'] as $taskid) { $sql_cmd = "Delete from tblToDoList where taskid=" .$taskid; $dbh->exec($sql_cmd); } } ?> </head> <body onload="ShowInsertTask(1);"> <h1><small>Add new Task</small></h1> <form action="" id="frmTask"> <div> <label for="lblName">Task Name:</label> <div > <input type="text" id="txtName" required> </div> <div > <label for="lblDate">Date</label> <div> <input type="date" id="txtDate" required> </div> <div > <label for="lblDesc">Description</label> </div> <div> <input type="text" id="txtDesc" > </div> <div > <label for="lblPriority">Priority</label> </div> <div > <select id = "ddlPriority" > <option value = "1">1</option> <option value = "2">2</option> <option value = "3">3</option> <option value = "4">4</option> <option value = "5">5</option> <option value = "6">6</option> <option value = "7">7</option> <option value = "8">8</option> <option value = "9">9</option> <option value = "10">10</option> </select> </div> <div> <div > <label for="lblStatus">Status:</label></div> <div> <select id = "ddlStatus" > <option value = "Completed">Completed</option> <option value = "In Progress">In Progress</option> <option value = "Not Yet Started">Not Yet Started</option> </select> </div> <br> <div> <button type="button" class="btn" onclick="ShowInsertTask(2)">Add Task</button> </div> </div> </form> </div> <br> <div> <div style="float:left"><h4>To do List</h4></div> <div style="float:right"> <button type="submit" onclick="RemoveData(3);">Delete List</button></div> </div> <div> <form action="todolist.php" method="post"> <div> <table id ="tblToDoList" > <thead> <tr style="background-color: #d3edf8;"> <th><button type="submit" class="btn">Delete </button></th> <th>Task Name </th> <th> Date </th> <th> Priority </th> <th> Status </th> <th> Description </th> </tr> </thead> <tbody id="tblData"> </tbody> </table> </div> </form> </div> <script type="text/javascript"> //<![CDATA[ function ShowInsertTask(opId) { var sTaskName = document.getElementById("txtName").value; var dDate = document.getElementById("txtDate").value; var sDescription = document.getElementById("txtDesc").value; var iPriority= document.getElementById("ddlPriority").value; var sStatus = document.getElementById("ddlStatus").value; /* check taskname and date should not be blank */ if(opId == 2) { if(sTaskName == "" || dDate == "") { alert("date and task name are mandatory, please fill those!!"); if(sTaskName == "") { document.getElementById("txtName").focus(); } else { document.getElementById("txtDate").focus(); } return false; } } InsertDisplayTask(opId,sTaskName, dDate, sDescription,iPriority, sStatus); } ----------------------------------------------------------------------------- /* This function removes all the tasks from the database by calling the same InsertDisplayTask function, which is written in an utility.js file */ ----------------------------------------------------------------------------- function RemoveData(opId) { var vResponse= confirm("Are you sure you want to delete the list?"); if(vResponse == true) { var sTaskName = ""; var dDate = ""; var sDescription = ""; var iPriority = 0; var sStatus = ""; InsertDisplayTask(opId,sTaskName, dDate, sDescription,iPriority, sStatus); } } //]]> </script> <noscript> document.write("Please enable JavaScript in your browser to experience all the feature."); </noscript> </body> </html>
My Web Design & Development

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.