Я пытаюсь создать 2 разных объекта из массивов внутри объекта.
Я создал таблицу, которая передает все данные методом POST.
Например, вот чтоформа отправляется, когда я добавляю данные в 2 строки:
![enter image description here](https://i.stack.imgur.com/Q7gYs.png)
{ fm_tipo_comp_select: [ '1', '3' ],
fm_tipo_gasto: [ '1', '6' ],
fm_serie: [ '1234', '4321' ],
fm_ndoc: [ '11551151', '222111' ],
fm_ruc: [ '74111', '17144151658' ],
fm_fecha: [ 'May 16, 2019', 'May 25, 2019' ],
fm_moneda: [ '2', '5' ],
fm_retencion: [ '16', '16' ] }
Мне нужно разделить это следующим образом:
Объект1
{ fm_tipo_comp_select: '1',
fm_tipo_gasto: '1',
fm_serie: '1234',
fm_ndoc: '11551151',
fm_ruc: '74111',
fm_fecha: 'May 16, 2019',
fm_moneda: '2',
fm_retencion: '16' }
Объект 2
{ fm_tipo_comp_select: '3',
fm_tipo_gasto: '6',
fm_serie: '4321',
fm_ndoc: '222111',
fm_ruc: '17144151658',
fm_fecha: 'May 25, 2019',
fm_moneda: '5',
fm_retencion: '16' }
Как я могу таким образом отделить свой объект или, как лучше, как отправить форму с разделенными объектами.
IЯ использую nodejs.
---- EDIT ----
Это моя форма:
form#fm-form.col.s12(method='POST', action='/facturas/m/add')
.row
a.btn-floating.btn-small.waves-effect.waves-light.green.add-btn
i.material-icons add
table#fm-table
thead
tr
th Tipo de Comprobante
th Tipo de Gasto
th Serie
th N° Documento
th RUC
th Razón Social
th Fecha
th Moneda
th Monto
th Cod. Retención
th Eliminar
tbody
tr
td
.inputfield
select(name='fm_tipo_comp_select')
option(value='', disabled='', selected='') Comprobante
each row in tipo_comprobante
option(value=row.tipo_comprobante_id) #{row.tipo_comprobante_name}
label Tipo comprobante
td
.inputfield
select(name='fm_tipo_gasto')
option(value='', disabled='', selected='') Tipo gasto
each row in tipo_gasto
option(value=row.tipo_gasto_id) #{row.tipo_gasto_name}
label Tipo gasto
td
.inputfield
input#fm_serie.validate.right-align(type='text', name='fm_serie')
td
.inputfield
input#fm_ndoc.validate.right-align(type='text', name='fm_ndoc')
td
.inputfield
input#fm_ruc.validate.right-align(type='text', name='fm_ruc')
td
.inputfield
input#fm_rs.validate.right-align(type='text', name='fm_rs' disabled)
td
.inputfield
input#fm_fecha.datepicker.validate(type='text', name='fm_fecha')
td
.inputfield
select(name='fm_moneda')
option(value='', disabled='', selected='') Moneda
each row in currency
option(value=row.currency_id) #{row.currency_name}
label Moneda
td
.inputfield
input#fm_monto.validate(type='number')
td
.inputfield
select(name='fm_retencion')
option(value='', disabled='', selected='') Retención
each row in rendiciones
option(value=row.rendicion_id) #{row.rendicion_name}
label Retención
td
.inputfield
a.btn-floating.btn-small.waves-effect.waves-light.red.delete-btn
i.material-icons delete
.row.fm_buttons_row
.input-field.col.s4
button.btn.waves-effect.waves-light.red(type='submit', name='action')
| Cancelar
i.material-icons.right cancel
.input-field.col.s4
button.btn.waves-effect.waves-light(type='submit', name='action')
| Guardar
i.material-icons.right save
.input-field.col.s4
button.btn.waves-effect.waves-light(type='submit', name='action')
| Enviar
i.material-icons.right send