<table class="table table-striped table-bordered table-hover" id="pickup"> <thead> <tr> <th width="12%">รหัสสินค้า</th> <th width="45%">ชื่อสินค้า</th> <th width="9%" style="text-align: right;">จำนวน</th> </tr> </thead> <tbody> <tr> <td><span id='snum'>1.</span></td> <td><input class='form-control nCode_product' type='text' name='nCode_product[]'></td> <td><input class='form-control cName_product' type='text' name='cName_product[]'></td> <td><input class='form-control amount' style='text-align: right;' type='number' name='amount[]'></td> </tr> </tbody> </table> <script language="JavaScript"> document.onkeydown = chkEvent function chkEvent(e) { var keycode; if (window.event) keycode = window.event.keyCode; //*** for IE ***// else if (e) keycode = e.which; //*** for Firefox ***// if(keycode==13) { return false; } } </script>
$(function(){ $('body').on('click','.nCode_product',function(){ autocom_nCode($(this)); }); function autocom_nCode(el) { el.autocomplete({ minLength: 2, source: function (query, process) { $.post('../Purchase/returnProduct.php', { nCode_product_filter: query.term }, function (response) { var res = $.parseJSON(response); return process(res); }); }, select: function (event, ui) { event.preventDefault(); el.closest('tr').find('.nCode_product').val(ui.item.nCode_product); el.closest('tr').find('.nId_product').val(ui.item.nId_product); el.closest('tr').find('.cName_product').val(ui.item.cName_product); el.closest('tr').find('.amount').val(1); } }); } });
$('.nCode_product').change(function(){ $.ajax({ url: '/GetProductName.php/?id='+this.value}).done((rs)=>{ $('.cName_product').val(rs); }); });
$id=filter_input(INPUT_GET, 'id'); $testname=get_name_from_query($id); echo $testname;
$('.nCode_product').change(function(){ $.ajax({url:'../Checking/GetProductName.php?nCode_product='+this.value}).done((rs)=>{ let data = $.parseJSON(rs)[0]; $('.cName_product').val(data.cName_product); $('.nId_product').val(data.nId_product); $('.amount').focus(); }); })
$('.nCode_product').change(function(){ var tr = $(this).parents('tr').eq(0); // กำหนด tr ที่จะทำงานด้วย $.ajax({url:'../Checking/GetProductName.php?nCode_product='+this.value}).done((rs)=>{ let data = $.parseJSON(rs)[0]; $(tr).find('.cName_product').val(data.cName_product); // ถ้าไม่มี tr ครอบ ทุก .cName_product จะเปลี่ยนหมด $(tr).find('.nId_product').val(data.nId_product); $(tr).find('.amount').eq(0).focus(); // focus ต้องการ element เดียว อ้างอิง array ไม่ได้ }); })
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง