I have a code in javascript that takes the value of the quantity field with onkeypress however I would also need to get the value of the id field or that the value will be sent via ajax to another page for this one doing an update only that I am not being able to send also send the value of the field id someone has a suggestion, I would like this by sending the value of the field id and the field qtd to the function parameter by the onkeypress of the qtd field.
follow the code in ajax:
<script>
function update(str) {
//var codigo = document.getElementById('codigo').value;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("result").inner =
this.responseText;
}
};
xhttp.open("GET", "update.php?qtd="+str+"&unidade="+str+"&desc="+str+"&custo="+str, true);
alert(str);
xhttp.send();
}
</script>
follow the code in php:
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Código</th>
<th>Quatidade</th>
<th>Unidade</th>
<th>Descrição</th>
<th>Custo</th>
<th>Data</th>
</tr>
</thead>
<?php
while($result = @mysql_fetch_array($sql)){
echo "<tbody>";
echo "<tr class='odd gradeX' id='result'>";
echo "<td><input type='text' disabled='disabled' id='codigo' name='codigo' value='".$result[0]."'/></td>";
echo "<td><input type='text' onkeypress='update(this.value)' id='qtd' name='qtd' value='".$result[1]."'/></td>";
echo "<td><input type='text' onkeypress='update(this.value)' id='unidade' name='unidade' value='".$result[2]."'/></td>";
echo "<td><input type='text' onkeypress='update(this.value)' id='desc' name='desc' value='".$result[3]."'/></td>";
echo "<td><input type='text' onkeypress='update(this.value)' id='custo' name='custo' value='".$result[4]."'/></td>";
echo "<td><input type='text' disabled='disabled' value='".$result[5]."'/></td>";
echo "</tr>";
echo "</tbody>";
}
?>
</table>