0
Sorry about the title of the post, but I’m not thinking of something to specify what I want (feel free to edit). It’s 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>
when clicked calls a function jquery
:
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);
}
}
});
}
}
That one form
works normally, and I need the following: include the parameter id
on the form form
and send it along with the form data.
Is there any way to do that?
Have you tried
form.append('id', document.getElementById('inputID').value);
?– Valdeir Psr