Greetings everyone! Is there a way in JavaScript to convert this data structure:
{
Control[0].Eseguito: "true"
Control[0].Id:"2"
Control[0].Nota:""
Control[1].Eseguito: "true"
Control[1].Id:"2"
Control[1].Nota:""
}
into a JavaScript Array like this:
Control: Array(2)
0: {Id: '1', Eseguito: "true", Nota: ''}
1: {Id: '1', Eseguito: "true", Nota: ''}
UPDATE
let myForm = document.getElementById('ControlForm');
var Controls = Object.fromEntries(new FormData(myForm).entries());
In my ExecControl.cshtml file, I have a situation similar to this, just a snippet of the code:
@{
int Index = 0;
}
@for (int i = 0; i < Model.ListControls.Length; i++)
{
for (int j = 0; j < Model.ListControls[i].Controls.Length; j++)
{
...
<input type="text" style="width:100%;" name="Control[@Index].Nota"/>
input type="text" style="width:100%;" name="Control[@Index].Id" value="@ListControls[i].Controls.Id"/>
...
}
}