I made a Django project, a calibration list with reference machines. Each calibration has a full page of calculations, another page takes data from the calculations and renders it on a digital certificate page. I pass the data from the calculation page to the certificate page using local storage, but the problem is that when I open multiple certificates, they don’t update automatically. I have to open the calculation page of one certificate for it to render the certificate with the correct data. If I open another certificate, it still has the data from the previous one, and that will be a problem if I want to send these certificates to the client and they have data saved from other calculations.
`function calculoErrorProm(rowElement) {
let LCIBCElement = rowElement.querySelector('.LCIBC');
let LCPElement = rowElement.querySelector('.LCP');
let EPElement = rowElement.querySelector('.EP');
let EElement = rowElement.querySelector('.E');
let LCIBCText = LCIBCElement.textContent;
let LCIBC = parseFloat(LCIBCText.replace(/,/g, '.'));
let LCPText = LCPElement.textContent;
let LCP = parseFloat(LCPText.replace(/,/g, '.'));
let EPText = EPElement.textContent;
let EP = parseFloat(EPText.replace(/,/g, '.'));
let E = LCIBC - (LCP - EP);
EElement.textContent = E.toPrecision(4);
// Save the values of E in an array and store it in localStorage
let valoresE = JSON.parse(localStorage.getItem('valoresE')) || [];
valoresE.push(E.toPrecision(4));
localStorage.setItem('valoresE', JSON.stringify(valoresE));
}`
`function rellenarTablaConDatosE() {
// Retrieve the values of E from localStorage
let valoresE = JSON.parse(localStorage.getItem('valoresE')) || [];
// Get all cells with class E
let celdasE = document.querySelectorAll('.E');
// Fill the cells with the values of E
valoresE.forEach((valor, index) => {
if (index < celdasE.length) {
// Convert the value to a number and format it to two decimals
let valorConDosDecimales = parseFloat(valor).toFixed(2);
celdasE[index].textContent = valorConDosDecimales;
}
});
}`
What’s the solution to not storing it in the database because there are more than 1000 certificates every year? I just need to perform the calculations in JavaScript and associate them with their certificate ID.
user24809821 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.