NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

function login() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;

// Send login request to the backend
fetch('http://localhost:5000/authentication/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, password })
})
.then(response => {
if (response.ok) {
// Hide login form, show class selection
document.getElementById('loginForm').style.display = 'none';
document.getElementById('classSelection').style.display = 'block';
} else {
// Handle invalid login
alert('Invalid login credentials');
}
})
.catch(error => {
console.error('Error:', error);
});
}

function getStudents(classNumber) {
// Fetch students from the backend based on class number
fetch(`http://localhost:5000/student/${classNumber}`)
.then(response => response.json())
.then(data => {
displayStudents(data, classNumber);
})
.catch(error => {
console.error('Error:', error);
});
}

function displayStudents(students, classNumber) {
const studentsList = document.getElementById('studentsList');
studentsList.innerHTML = '';

students.forEach(student => {
const studentDiv = document.createElement('div');
studentDiv.innerHTML = `
<p>ID: ${student.id}</p>
<p>Name: ${student.name}</p>
<p>Assignment: ${student.assignment}</p>
<p>Attendance: ${student.attendance}</p>
<p>Contact: ${student.contact}</p>
<button onclick="updateStudent(${classNumber}, ${student.id})">Update</button>
<button onclick="deleteStudent(${classNumber}, ${student.id})">Delete</button>
<hr>
`;
studentsList.appendChild(studentDiv);
});

// Add a form for adding a new student
const addForm = document.createElement('div');
addForm.innerHTML = `
<h2>Add New Student</h2>
<label for="name">Name:</label>
<input type="text" id="name">
<label for="assignment">Assignment:</label>
<input type="text" id="assignment">
<label for="attendance">Attendance:</label>
<input type="text" id="attendance">
<label for="contact">Contact:</label>
<input type="text" id="contact">
<button onclick="addStudent(${classNumber})">Add Student</button>
`;
studentsList.appendChild(addForm);
}

function updateStudent(classNumber, studentId) {
// Implement logic to update a student (similar to addStudent)
alert(`Update student with ID ${studentId} in class ${classNumber}`);
}

function deleteStudent(classNumber, studentId) {
// Implement logic to delete a student
alert(`Delete student with ID ${studentId} in class ${classNumber}`);
}

function addStudent(classNumber) {
const name = document.getElementById('name').value;
const assignment = document.getElementById('assignment').value;
const attendance = document.getElementById('attendance').value;
const contact = document.getElementById('contact').value;

// Send add student request to the backend
fetch(`http://localhost:5000/student/${classNumber}/add`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ name, assignment, attendance, contact })
})
.then(response => {
if (response.ok) {
// Refresh the students list after adding
getStudents(classNumber);
} else {
// Handle error
alert('Error adding student');
}
})
.catch(error => {
console.error('Error:', error);
});
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.