How I can post all the information in database to it's designated textboxes. I need to post the value on textboxes for example, Pr # data into pr_num textboxes and so on. The problem is my ajax function is only for one textboxes. How I can post it in every textboxes? Any Help will appreciate.
Table Structure
Pr # | Supplier | Receipt # | Receiver |
--------------------------------------------
321-B | Villman | 312312331 | John |
556-B | Dockers | 903232317 | William |
Ajax.php
<?php
if(isset($_POST['pr_code'])) {
$pr_code= $_POST['pr_code'];
$sql = $mysqli->query("SELECT * FROM pr_table WHERE pr='$pr_code'");
while($row = $sql->fetch_assoc())
{
$pr= $row['pr'];
$supplier = $row['supplier'];
$receipt_num= $row['receipt_num'];
$receiver= $row['receiver'];
}
echo $pr;
echo $supplier;
echo $receipt_num;
echo $receiver;
}
?>
index.php
<select id="pr">
<?php ... ?>
</select>
<input id="pr_num">
<input id="supplier">
<input id="receipt">
<input id="receiver">
<script type="text/javascript">
$(document).ready(function()
{
$('input[id="pr"]').change(function()
{
var prjt_code = $("#pr").val();
$.ajax({
type: "POST",
url: "ajax.php",
data :"pr_code="+pr_code,
dataType:'html',
type:'POST',
success:function(data){
$('#pr_num').val(data);
}
});
return false;
});
});
</script>