Sorry for the title of the post, is that I'm not thinking about something to specify what I'm wanting (feel free to edit). It is as follows:
I have an html form and a button:
<form id="formflor" method="post">
<input type="text" class="form-control" id="codigo" name="codigo" placeholder="código de barras">
<input type="text" class="form-control" id="nome" name="nome" placeholder="Rosa">
<textarea class="form-control" id="informacoes" name="informacoes" rows="3" placeholder="descreva aqui..."></textarea>
<input type="file" id="imagem" name="imagem">
<button type="button" class="btn btn-primary" onclick="editaFlor(1, 'jasmim');">Enviar dados</button>
</form>
that when clicked calls a jquery
function:
function editaFlor(id, descricao){
if (confirm("Confirma a alteração de " + descricao + "?"))
{
var myForm = document.getElementById('formflor');
var form = new FormData(myForm);
$.ajax({
type: "POST",
url: "functions/editarFlor.php",
data: form,
cache: false,
contentType: false,
processData: false,
success: function(data) {
if (data == 'ok'){
alert(descricao + ' editado com sucesso!');
listaFlor();
}
else{
alert(data);
}
}
});
}
}
This form
works normally, and I need to include the id
parameter in the form
form and send it along with the form data.
Is there any way to do this?