|
 |
|
ขอคำปรึกษาหน่อยครับ ถ้าค้นหาด้วย ajaxแล้วต้องการส่งไอดีจากแถวเดียวกันไปอัพเดต ต้องทำอย่างไรครับ |
|
 |
|
|
 |
 |
|
วิธีที่ 1 ค้นหาแล้วให้ ajaxส่งไอดีมาใส่ textbox=txtEmpID แต่เวลาส่งฟอร์มแล้วไม่เจอค่าของไอดี
Code (PHP)
<form action="picking-save.php" method="POST">
<input type="text" id="txtRFID" name="txtRFID" />
<input type="text" id="txtEmpID" name="txtEmpID" />
<button type="submit">ok</button>
</form>
<script type="text/javascript">
$(document).ready(function(){
$('#txtRFID').keyup(function(){
var txt = $(this).val();
if (txt != '')
{
$.ajax({
url:"returnFetch.php",
method:"POST",
data:{search:txt},
dataType: "text",
success:function(data)
{
$('#txtEmpID').val(data);
}
});
}
else
{
$('#txtEmpID').val('');
}
});
});
</script>
วิธีที่ 2 ค้นหาโดย ajaxเช่นกัน แต่อยู่ในรูปแบบลูปตาราง เมื่อค้นหาแล้วทำการส่งฟอร์ม มันจะนำค่าที่อยู่ลำดับสุดท้ายไปอัพเดต
Code (PHP)
<table>
<?php
while($resulty = sqlsrv_fetch_array($queryer, SQLSRV_FETCH_ASSOC))
{
?>
<tr class="TRfid">
<td><?php echo $resulty["RFIDNo"];?></td>
<td><input id="txtEmpID" name="txtEmpID" value="<?php echo $resulty["EmpID"];?>" /></td>
</tr>
<?php
}
?>
<script type="text/javascript">
$(document).ready(function(){
$("#txtRFID").keyup(function(){
_this = this;
$.each($(".TRfid"), function() {
if($(this).text().toLowerCase().indexOf($(_this).val().toLowerCase()) === -1)
$(this).hide();
else
$(this).show();
});
});
});
</script>
Tag : PHP, Ms SQL Server 2016, HTML5, JavaScript, Ajax, XAMPP

|
|
 |
 |
 |
 |
Date :
2019-05-27 12:58:25 |
By :
Bang23 |
View :
599 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ input array
<input type="text" name="name[]">
<input type="checkbox" name="name[]">
ทดลองเขียน แล้วทดลองเล่น ให้รู้เรื่องและเข้าใจ ก่อนที่จะทำอย่างอื่นต่อไป
|
 |
 |
 |
 |
Date :
2019-05-27 20:09:06 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|