0

I have a form with many inputs (name, birthday, address, height, etc) and I have a button for that form. I would like to know how can I get an array of objects from that form with a single button click. I would like to know how to do this with a json output similar to this:

{   name: 'Razao social',
    enterprise number: 'Nome Fantasia',
    cnpj: '123456',
    products: {
        [   indice: 1,
            descricaoProduto: 'Descrição produto',
            unidadeMedida: 'unidadeMedida',
            qtdeEstoque: '123',
            valorUnitario: '1554.00',
            valorTotal: '2555.00'       
        ],
        [   indice: 2,
            descricaoProduto: 'Descrição produto',
            unidadeMedida: 'unidadeMedida',
            qtdeEstoque: '123',
            valorUnitario: '1554.00',
            valorTotal: '2555.00'       
        ],
    }
    anexos: {
        [   indice: 1,
            nomeArquivo: 'iouahsiuahusihausihiahiuah',
            blobArquivo: 'iouahsiuahusihausihiahiuah'
        ],
        [   indice: 2,
            nomeArquivo: 'iouahsiuahusihausihiahiuah',
            blobArquivo: 'iouahsiuahusihausihiahiuah'
        ],  
    }

}

I tried to do this by creating an object with all the values ​​but it didn't work

Heitor Kenzou
  • 69
  • 2
  • 7
  • HTML forms return a [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects) object not a JSON object. This article ( https://stackoverflow.com/questions/41431322/how-to-convert-formdata-html5-object-to-json )should be helpful in converting the FromData into JSON If this isn't what you need, can you provide a snip of code to show what you have now that isn't working as well as provide any frameworks you may be using? – Seth Nov 23 '22 at 03:07

0 Answers0