0
I am doing an activity that consists of recording data obtained from a form in the sessionStorage with the Register button, and with the Display button, show the recorded data. I cannot show this recorded data in the div. How can I do?
Here’s what I’ve done so far
window.addEventListener("load", function(){
document.querySelector("#cad").addEventListener("click", cadastrar);
document.querySelector("#exibir").addEventListener("click", exibir);
})
function cadastrar() {
if(typeof(sessionStorage) == 'undefined'){
alert("Seu navegador não suporta HTML5 localStorage.")
}else{
var nome = window.sessionStorage.setItem("nome", $("#nome").val());
var rgm = window.sessionStorage.setItem("rgm", $("#rgm").val());
var par = window.sessionStorage.setItem("nota_parcial", $("#nota_parcial").val());
var pro = window.sessionStorage.setItem("nota_pro", $("#nota_pro").val());
var reg = window.sessionStorage.setItem("nota_regi", $("#nota_regi").val());
}
}
function exibir(){
if (sessionStorage.length > 0){
var result = $("#resp");
onome = $("#nome").val(sessionStorage.getItem("nome"));
orgm = $("#rgm").val(sessionStorage.getItem("rgm"));
npar = $("#nota_parcial").val(sessionStorage.getItem("nota_parcial"));
npro = $("#nota_pro").val(sessionStorage.getItem("nota_pro"));
nreg = $("#nota_regi").val(sessionStorage.getItem("nota_regi"));
result.innerHTML += onome;
result.innerHTML += orgm;
result.innerHTML += npar;
result.innerHTML += npro;
result.innerHTML += nreg;
}else{
alert("Nada foi Gravado!");
}
}