0

I have a form:

<form id="formId" onsubmit="addStudentData()"></form>

And javascript function(find HERE HERE HERE) :

function addStudentData() {
let name = document.getElementById('sname').value;
let id = document.getElementById('sid').value;
let year = document.getElementById('syear').value;
let stream = document.getElementById('sstream').value;

/* Making a JSON object using the form values */
let studentObj = { 'name': name, 'year': year, 'stream': stream };

/* Pushing record to sessionStorage after stringify JSON Object*/
sessionStorage.setItem(id, JSON.stringify(studentObj));

/* Redirecting back to home page*/

**// HERE HERE HERE**
window.location.href = "index.html"
}

I don't understand why my javascript function is not opening 'index.html' after storing the data in sessionStorage. Also, if you can, state another way to do it.

Ashutosh Sharma
  • 118
  • 2
  • 18

0 Answers0