HTML Start::
<input placeholder="Production Number" autocomplete="off" list="dlProdno" type="text" id="ProductionNo" /> <datalist id="dlProdno"></datalist>
HTML End
Jauery Part:
$(document).ready (function (){
Productionnodatalist()
function Productionnodatalist(){
debugger;
$.ajax({
type:"POST",
url:"loadproductioninfo.php",
data:{"type" : 'productionNo'},
success:function(data)
{
$('#dlProdno option').remove();
var obj = JSON.parse(data);
var content = '';
$.each(obj, function (key, val) {
content+='<option id="'+val.ProductionInfoMasterID+'" value="'+val.ProductionNo+'"></option>';
});
$('#dlProdno').append(content);
}
});
}
});
Data List Getvalue ID- code
var abc = $("#dlProdno option[value='" + $('#ProductionNo').val() + "']").attr('id');
alert(abc);
PHP Part:
if($Type== 'productionNo')
{
$data = array();
$sql="SELECT TOP (300) ProductionNo, ProductionInfoMasterID
FROM dbo.tbl_ProductionInfoMaster
ORDER BY ProductionInfoMasterID DESC";
$result=sqlsrv_query($sql_conn,$sql);
while($rows=sqlsrv_fetch_array($result))
{
$data[]=$rows;
}
echo json_encode($data);
}
php End
No comments:
Post a Comment
I am Safiqul Islam Tuhin