In my code, I have created an editable array where you can input student information. A button computes the grade for each student at the end of the line. Additionally, there are buttons to add rows for students and columns for different assignments.
Now, I want to enhance the functionality by adding two more buttons - one to save the filled array in a Cookie and another to load this information back into the array.
I'm currently facing a challenge when it comes to saving and loading data using cookies.
Below is the snippet of my code:
var ass = 1;
// Functions for calculating grades, adding rows and columns
...
// Buttons linking and functions for saving and loading cookies.
...
function save_cookie() {
setCookie("array", array, 30);
var array = document.getElementById("Student_Table");
alert (array + " saved");
}
function load_cookie(){ }
...
<table class="tg" id="Student_Table">
<tr>
<th class="tg-baqh">Student Name<br></th>
<th class="tg-baqh">Student ID<br></th>
<th class="tg-baqh">Assignment 1<br></th>
<th class="tg-baqh">Final Grade<br></th>
</tr>
<tr>
<td class="tg-yw4l" contenteditable="true"></td>
<td class="tg-yw4l" contenteditable="true"></td>
<td class="tg-lqy6" contenteditable="true"></td>
<td></td>
</tr>
</table>
<a href="#" class="myButton" id="click" onclick="Grade()">grade</a>
<a href="#" class="myButton" id="click2" onclick="add_row()">add row</a>
<a href="#" class="myButton" id="click3" onclick="add_column()">add column</a>
<a href="#" class="myButton" id="click4" onclick="save_cookie()">Save data</a>
<a href="#" class="myButton" id="click5" onclick="load_cookie()">Load data</a>
Your assistance is greatly appreciated.
Regards,
Eric