OneCompiler

Sample Edit function

1613

Example code for editing record

function accepts parameter of index which we will use as reference to update record in the array

//edit function sets editMode and currentIndex
function editStudent(index){
  editMode = true; 
  currentIndex = index; 
  
  let editStudent = students[index];
  document.getElementById('student_name').value = editStudent.student_name;
  document.getElementById('username').value = editStudent.username;
  document.getElementById('password').value = editStudent.password;
}