0
I am mounting a table via Javascript as follows:
itens += '<table border="0" class="table table-hover ">'+
'<thead>'+
'<tr class="table">'+
'<th style="text-align:center;" class="col-md-3">Descrição</th>'+
'<th style="text-align:center;">Qtd</th>'+
'</tr>'+
'</thead>'+
'<tbody>';
$.ajax({
dataType: 'json',
url: "js/ajaxBuscarDados.php",
cache: false,
data: {id: id},
success: function(data) {
$('#modalAguarde').modal('hide');
if(data.retorno == 'ERRO'){
$('#modalAguarde').modal('hide');
$('#modalErro').modal('show');
$("#minhaTabela").html(itens);
}else{
itens += "<tr>";
itens += '<td><input disabled type="text" class="form-control" id="descricao" readonly="true" name="title" placeholder="'+ data[i].descricao +'"></td>';
itens += '<td><input type="text" class="form-control" id="qtd" name="qtd#'+data[i].id_i+'" value=""></td>';
itens += "</tr>";
}
itens += "</tbody></table>";
$("#minhadiv").html(itens);
}
}
});
Now comes my problem: When I perform form Submit, I return several Qtd fields plus table ID numbering. Followed by its respective value informed by the user.
How I can get the ID value plus the value the user entered?
EDIT:
My return in PHP: http://pastebin.com/W59yLR4L
A doubt, the ID value would not be what the user typed ? Or you refer to the name given to the "id"?
– MagicHat
The data field[i]. id_i comes from the database, it is this ID that I need to take along with the value entered by the user. Today it’s coming to me Qtd#1 -> 1 ---- Qtd#2 -> 200 etc..
– Felipe FM
Well I don’t know about jquery, but to get the value of inputs in pure js, you can use: var valor_input = Document.getElementById("id_do_input"). value; and ai vc works with the variable.
– MagicHat
@Magichat, thanks, but the value I can already catch, the problem is the ID that comes from the database! I updated my question with the result of my Submit
– Felipe FM
I did a "gambiarra" putting in the value field the ID, but ends up appearing this information to the user, if it deletes, already was, go error!
– Felipe FM
You can use the attribute "readonly" in the input... is one of the paths...
– MagicHat