CRUD Operation In JavaScript With Source Code
The CRUD Operation In JavaScript is developed using JavaScript, CSS, bootstrap, and HTML. CRUD stands for: Create, Read, Update and Delete. This Simple CRUD Operation In JavaScript is for adding the different records of the employees. This CRUD JavaScript project uses Crud Operation for the management system as mentioned in the title itself.
A CRUD Operation In AngularJS user can add the records of many employees with their name, code, salary and address. Here, the user can add the data, delete the data whenever they want, and also edit the records details if they have to update some data. This CRUD Operation In JavaScript Example includes a lot of JavaScript for making validations to certain parts of the project CRUD Operation Using JavaScript.
This JavaScript CRUD App also includes a downloadable Simple CRUD Operation In React JS project with source code for free, just find the downloadable source code below and click to start downloading. if you are using MySQL for storing your data, you can use this CRUD Operation In Node JS Using MySQL.
Watch the video here to see the full running CRUD Operation in JavaScript with Source Code
I have here a suggested list of Best JavaScript Projects with Source Code Free to download and I’m sure this can help you to improve your skills in JavaScript programming and web development as a whole.
To start creating a CRUD Operation In JavaScript, makes sure that you have any platform in creating a JavaScript, CSS, bootstrap, and HTML installed in your computer, in my case I will use Sublime Text.
Steps on how to create a CRUD Operation In JavaScript
CRUD Operation In JavaScript With Source Code
- Step 1: Open Sublime Text.
First after installing sublime text IDE, click “open” to start.
- Step 2: Create a HTML file.
Second click “file” and select “save as” and named it “index.html“
- Step 3: Create a CSS file.
Third click “file” and select “save as” and named it “style.css“
- Step 4: Create a JavaScript file.
Fourth click “file” and select “save as” and named it “script.js“
- Step 5: The actual code.
You are free to copy the code given below and paste to your different file created.
The Code Given Below Is For The Index.html Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Crud operation in javascript</title> <link type="text/css" rel="stylesheet" href="style.css"> </head> <body style="background-color: blue;"> <table> <tr> <td> <!--HTML form for crud operation--> <form autocomplete="off" onsubmit="onFormSubmit()"> <div> <label for="fullName">Full Name</label> <input type="text" name="fullName" id="fullName" > </div> <div> <label for="empCode">EMP Code</label> <input type="text" name="empCode" id="empCode" > </div> <div> <label for="salary">Salary</label> <input type="text" name="salary" id="salary"> </div> <div> <label for="city">City</label> <input type="text" name="city" id="city"> </div> <div class="form_action--button"> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </div> </form> </td> <td> <table class="list" id="employeeList"> <thead> <tr> <th>Full Name</th> <th>EMP Code</th> <th>Salary</th> <th>City</th> <th></th> </tr> </thead> <tbody> </tbody> </table> </td> </tr> </table> <script type="text/javascript" src="./script.js"></script> </body> </html> |
In this module which is the html file of the system.
The Code Given Below Is For The Style.css Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
body > table{ width: 80%; margin: 40px auto; background-color: lightblue; } table{ border-collapse: collapse; } table.list{ width: 100%; } td, th{ border: 1px solid #ddd; text-align: left; padding: 8px 15px; } tr:nth-child(even),table.list thead>tr{ background-color: #ddd; } input[type="text"], input[type="number"]{ width: 91%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; border-radius: 4px; } input[type="submit"],input[type="reset"]{ background: #eee; padding: 6px 12px; font-size: 1rem; cursor: pointer; border-radius: 30px; border: none; margin: 15px 0 10px; outline: none; } input[type="submit"]:hover{ background: #f3f3f3; } |
In this module which is the css file of the system.
The Code Given Below Is For The Script.js Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
var selectedRow = null; function onFormSubmit(e){ event.preventDefault(); var formData = readFormData(); if(selectedRow === null){ insertNewRecord(formData); }else{ updateRecord(formData) } resetForm(); } // Read operation using this function function readFormData(){ var formData = {}; formData["fullName"] = document.getElementById("fullName").value; formData["empCode"] = document.getElementById("empCode").value; formData["salary"] = document.getElementById("salary").value; formData["city"] = document.getElementById("city").value; return formData; } // Create operation function insertNewRecord(data){ var table = document.getElementById("employeeList").getElementsByTagName('tbody')[0]; var newRow = table.insertRow(table.length); var cell1 = newRow.insertCell(0); cell1.innerHTML = data.fullName; var cell2 = newRow.insertCell(1); cell2.innerHTML = data.empCode; var cell3 = newRow.insertCell(2); cell3.innerHTML = data.salary; var cell4 = newRow.insertCell(3); cell4.innerHTML = data.city; var cell5 = newRow.insertCell(4); cell5.innerHTML = `<a href="#" onClick='onEdit(this)'>Edit</a> <a href="#" onClick='onDelete(this)'>Delete</a>`; } // To Reset the data of fill input function resetForm(){ document.getElementById('fullName').value = ''; document.getElementById('empCode').value = ''; document.getElementById('salary').value = ''; document.getElementById('city').value = ''; selectedRow = null; } // For Edit operation function onEdit(td){ selectedRow = td.parentElement.parentElement; document.getElementById('fullName').value = selectedRow.cells[0].innerHTML; document.getElementById('empCode').value = selectedRow.cells[1].innerHTML; document.getElementById('salary').value = selectedRow.cells[2].innerHTML; document.getElementById('city').value = selectedRow.cells[3].innerHTML; } function updateRecord(formData){ selectedRow.cells[0].innerHTML = formData.fullName; selectedRow.cells[1].innerHTML = formData.empCode; selectedRow.cells[2].innerHTML = formData.salary; selectedRow.cells[3].innerHTML = formData.city; } function onDelete(td){ if(confirm('Are you sure you want to delete this record?')){ row = td.parentElement.parentElement; document.getElementById('employeeList').deleteRow(row.rowIndex); resetForm(); } } |
In this module which is the javascript file of the system.
Run Quick Virus Scan for secure Download
Run Quick Scan for secure DownloadDownloadable Source Code
Summary
This JavaScript Project With Source Code is simply in HTML, CSS, and JavaScript. Taking about the features of this system, the user can add the data, delete the data whenever they want, and also edit the records details if they have to update some data. This project includes a lot of javascript for making validations to certain parts of the project.
Related Articles
- Todo List In JavaScript With Source Code
- Currency Converter Project in JavaScript with Source Code
- Calculator In JavaScript Source Code
- Fibonacci Series In JavaScript With Source Code
Inquiries
If you have any questions or suggestions about CRUD Operation In JavaScript , please feel free to leave a comment below.