I suggest you look at the actual request body which the client is sending, using your browser's developer console (or at worst using tcpdump/wireshark, as long as it's not HTTPS).
Then it should be clear whether your Javascript is sending a "parcelas" form value, and if so what it contains. I note that you've passed a Javascript array (parcelasTabela) without JSON.stringify'ing it, so you'll have to see what it actually sends, if anything. My guess is that your issue is with the Javascript, not the Go. Given that this is a complex structured value, it might be better to make the whole request use JSON instead of form data though. On Monday, 3 April 2023 at 01:35:54 UTC+1 Wellington Arantes wrote: > Hello, > > I'm a noob about Golang, I'm studying and making samples... > I have a form HTML with inputs and a table > I created a function to update and execute a function javascript > In function, js get all information from HTML, inputs, and table, but in > golang > I don't get the table information...How can I do it? > > Function Golang > > func EditarCondicaoPagamento(w http.ResponseWriter, r *http.Request) { > //para post, put usase o ParseForm para ler os dados da pagina html > r.ParseForm() > > //r.FormValue("nome do campo no html") le o valor do campo no form html > > codCondicaoPagamento, _ := > strconv.ParseUint(r.FormValue("codCondicaoPagamento"), 10, 64) //pega o > codigo do servico que está no form html > > //le os valores do formulario html > condicaoPagamento, erro := json.Marshal(map[string]interface{}{ > "codCondicaoPagamento": codCondicaoPagamento, > "nome": r.FormValue("nome"), > "numParcelas": r.FormValue("numParcelas"), > //"codFormaPagamento": r.FormValue("codFormaPagamento"), > > "parcelas": r.FormValue("parcelas"), > }) > > > fmt.Println(bytes.NewBuffer(condicaoPagamento)) > > I don't get array value "parcelas" > > Result: > {"codCondicaoPagamento":4,"nome":"ENTRADA + 1","numParcelas":"2", > "parcelas":""} > > Function JS > > function editarCondicoesPagamento(evento){ > evento.preventDefault(); > > var parcelasTabela = []; > > var lista = $('#dtcondicoesPagamentoParcelamento'); > > $(lista).find("tr").each(function(index, tr) { > parcelasTabela.push(JSON.stringify({"codCondicaoPagamentoParc": > $(tr).find('td:eq(0)').html(), > "numParcela" : > $(tr).find('td:eq(1)').html(), > "dias" : > $(tr).find('td:eq(2)').html()})) > > }); > parcelasTabela.shift(); > > $.ajax({ > url : `/editar-condicoespagamento`, > method : "PUT", > data : { > codCondicaoPagamento : $( "#codCondicaoPagamento" ).val(), > nome : $( "#nome" ).val(), > numParcelas : $( "#numParcelas" ).val(), > parcelas : parcelasTabela, > } > }).done(function (){ > Swal.fire("Sucesso","Dados Atualizados com Sucesso!","success") > /*.then(function(){ > window.location = "/editar-cliente";//perfil > });*/ > }).fail(function() { > Swal.fire("Ops...","Erro ao Atualizar!","error") > }); > } > > Thanks! > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/42f75af7-4ea7-4f8a-8433-9e7c09e7d148n%40googlegroups.com.