In my json array called JsonTempArray, I have two fields: mappingId and Name.
When Male or Female is clicked, it will automatically generate 5 mappingIds (1 to 5) with the Name field empty. Example:
JsonTempArray[length] = {
mappingid: Number, //Number ranges from 1 to 5
Name:""
}
For each of the 5 people, there are text boxes to fill in their names.
I have the following code snippet to update the Name field:
for(var len=0;len<JsonTempArray.length;len++)
{
if (JsonTempArray[len].Mappingid === mapid ) {
JsonTempArray[len].Name = document.getElementById('txtName'+len).value;
}
}
Particular mappingId is passed when clicking on a textbox. For example:
1 John
2 Jack
3 Kin
4 Fin
5 Hol
However, after updating, the JsonTempArray looks like this:
5 Hol
5 Hol
5 Hol
5 Hol
5 Hol
I need assistance in updating each value in the loop. Thank you for your help.