I'm working on my homework and I can't figure out how can I make the table row to be editable on a click. For example, on click 'John' I can modify the name. The code below is just a small part of the code, just to get a clue of how the table is created. Any hint or solution is appreciated.
// Creating Table and Display DATA
let tableBody = document.getElementsByTagName('tbody')[0];
let tr = document.createElement('tr');
let ShowID = document.createElement('td');
let ShowName = document.createElement('td');
let ShowSurname = document.createElement('td');
let ShowAge = document.createElement('td');
let ShowPosition = document.createElement('td');
let ShowYofExperience = document.createElement('td');
let ShowEducation = document.createElement('td');
let ShowStatus = document.createElement('td');
let ShowNote = document.createElement('td');
for(let i = 0; i < candidates.length; i++){
let currentCandidate = candidates[i];
ShowID.innerText = currentCandidate.id;
ShowName.innerText = currentCandidate.name;
ShowSurname.innerText = currentCandidate.surname;
ShowAge.innerText = currentCandidate.age;
ShowPosition.innerText = currentCandidate.position;
ShowYofExperience.innerText = currentCandidate.experience;
ShowEducation.innerText = currentCandidate.education;
ShowStatus.innerText = currentCandidate.status;
ShowNote.innerText = currentCandidate.note;
}
// Checkbox
let ShowCheck = document.createElement('input');
ShowCheck.type = 'checkbox'
ShowCheck.id = 'checked';
ShowCheck.value = 'true';
tr.appendChild(ShowCheck);
tr.appendChild(ShowID);
tr.appendChild(btnPreview);
tr.appendChild(ShowName);
tr.appendChild(ShowSurname);
tr.appendChild(ShowAge);
tr.appendChild(ShowPosition);
tr.appendChild(ShowYofExperience);
tr.appendChild(ShowEducation);
tr.appendChild(ShowStatus);
tr.appendChild(ShowNote);
tr.appendChild(btnDelete);
tableBody.appendChild(tr);
let divShow = document.getElementById('content');
divShow.style.display = 'block'; // display table
clearForm(); // Clear Form Inputs
<div id="content" style = 'display:none;'>
<div id="results">
<table id = 'table' class = 'dnone'>
<tr>
<td>#</td>
<td>Candidate ID</td>
<td>Preview Candidate</td>
<td>Candidate Name</td>
<td>Candidate Surname</td>
<td>Candidate Age</td>
<td>Candidate Position</td>
<td>Candidate Years of Exp.</td>
<td>Candidate Education</td>
<td>Candidate Status</td>
<td>Candidate Note</td>
<td>Delete Record</td>
</tr>
<tbody>
</tbody>
</table>
<button id = 'btnDeleteAll'>Delete All</button>
</div>
</div>
