You can use Ajax with jQuery:
var field = $("input[name=adicional]");//Pega o seu campo
$.ajax("pagina.php", {
"type": "POST",
"data": {
"id": field.attr("id"), //Envia o id
"adicional": field.val() //Envia o valor
}
}).done(function(data) {
alert(data);
}).fail(function(a, b) {
alert(b);
});
PHP must be something like:
<?php
$id = $_POST['id'];
$valor = $_POST['adicional'];
However if you have little knowledge of ajax and have urgency in delivering the project, then recommend to do by pure html like this:
<input type="hidde" name="adiciona-id" value="Leite Ninho">
<input type="checkbox" name="adicional" value="2.00">
PHP must be something like:
<?php
$id = $_POST['adiciona-id'];
$valor = $_POST['adicional'];
I do not know how this your html code and not php, because this you did not put in the question, I answered what is inside what was asked, but I believe that regardless of the code the logic here applies to "almost anywhere".
This input is inside a form?
– Giancarlo Abel Giulian
Yes it is inside a form
– Alfredo Lima
You’ll have to use javascript to catch it and send it to php ... or concatenate value by a delimiter and give it a
explode()
in php.– rray
No, bro. Connect... the table in the database already inserts a ID automatic if you configure the
auto_increment
.– Diego Souza
Thank you very much
– Alfredo Lima