I have task which need to convert from input value to format object array like this:
[{
id: 1,
worker_id: 2,
status:1
},{
id: 2,
worker_id: 2,
status: 1
},{
id: 3,
worker_id: 2,
status:1
}]
I have multiple row for my input.
<!-- row1 -->
<input type="text" id="id" value="1"/>
<input type="text" id="worker_id" value="2"/>
<input type="text" id="status" value="1"/>
<!-- row2 -->
<input type="text" id="id" value="2"/>
<input type="text" id="worker_id" value="2"/>
<input type="text" id="status" value="1"/>
<!-- row3 -->
<input type="text" id="id" value="2"/>
<input type="text" id="worker_id" value="2"/>
<input type="text" id="status" value="1"/>
<input type="submit" value="submit" />
How can I do this in jQuery? Thank you for any help!
updated
Once I click button submit, can this format pass to text field?
[[1,2,1],[2,2,1],[3,2,1]]