In an array of objects, you know one value of one of the objects and how to modify the other values of that object.

if an array is known

items: [
    {name: "zhangsan",
     score: 0
    },
    {name: "lisi",
     score: 0
    }
],

in a form, the select tag binds the input box corresponding to items.name, and the variable value changingScore
when name is selected as "zhangsan" in the select drop-down menu, how can
add changingScore to items [0] .score after submission?

it"s best not to use for loops, because there may be a lot of data in the array

Mar.11,2021

then you can save the currently selected index value in a hidden input [id= "selectIndex"]. When select is selected, the selected index is stored in the hidden input, and then when submitted, set it directly through index,

.
// 
document.querySelector("-sharpselectIndex").value = index;
let index = parseInt(document.querySelector("-sharpselectIndex"));
items[index].score = changingScore;

or store the selected value in localStorage or sessionStorage. The idea is to store, update and maintain an index value.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c445-4133f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c445-4133f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?