|
|
|
รบกวนผู้รู้ครับ มีวิธี ทำ นำ javascript มาใช้ ใน php ไหมครับ |
|
|
|
|
|
|
|
Code (JavaScript)
<script type="text/javascript">
$(document).ready(function(){
var url="/aut_asset/modules/ajax_asset.php?action=view";
var edit_url = "";
$.getJSON(url,function(json){
$("#tbasset tbody").html("");
$.each(json.assets,function(i,dat){
var stat = dat.stat;
edit_url = "";
edit_url = "/aut_asset/index.php/edit_asset/";
edit_url += dat.Id;
var spancl = "";
if( stat == "1"){
spancl = '<span class="status-metro status-active" title="Active">Active</span>';
}
if( stat == "2"){
spancl = '<span class="status-metro status-disabled" title="Repair">Repair</span>';
}
if( stat == "3"){
spancl = '<span class="status-metro status-suspended" title="Revoke">Revoke</span>';
}
var tblRow =
"<tr>"
+"<td><a href="+edit_url+">"+dat.asset_id+"</a></td>"
+"<td>"+dat.namethai+"</td>"
+"<td>"+dat.nameeng+"</td>"
+"<td>"+dat.descriptions+"</td>"
+"<td data-value="+dat.stat+">"+spancl+"</td>"
+"</tr>" ;
$(tblRow).appendTo("#tbasset tbody");
});
});
});
</script>
TO
Code (JavaScript)
var url="/aut_asset/modules/ajax_asset.php?action=view&Id="+"<?php echo $_GET['Id']; ?>";
$.getJSON(url,function(json){
$.each(json.assets,function(i,dat){
document.getElementById("txtid").value = dat.Id;
document.getElementById("txtassetid").value = dat.asset_id;
document.getElementById("txtnamethai").value = dat.namethai;
document.getElementById("txtnameeng").value = dat.namethai;
document.getElementById("txttype").value = dat.type_id;
document.getElementById("txtprocesscircuit").value = dat.processcircuit;
document.getElementById("txtdescriptions").value = dat.descriptions;
document.getElementById("txtsite").value = dat.site;
document.getElementById("txtdepartment").value = dat.department_id;
document.getElementById("txtemphasis").value = dat.emphasis_id;
document.getElementById("txthoursperday").value = dat.hoursperday;
document.getElementById("txtbrand").value = dat.brand;
document.getElementById("txtmodel").value = dat.model;
document.getElementById("txtserial").value = dat.serial;
document.getElementById("txtwatt").value = dat.watt;
document.getElementById("txthorsepower").value = dat.horsepower;
document.getElementById("txtconstructor").value = dat.constructor_id;
document.getElementById("txtvendor").value = dat.vendor_id;
document.getElementById("txtcontact").value = "";
document.getElementById("txtaddress").value = "";
document.getElementById("txtphone").value = "";
document.getElementById("txtfax").value = "";
document.getElementById("txtprice").value = dat.price;
document.getElementById("temp_image").value = dat.image;
$('#blah').attr('src',"/aut_asset/file_upload/"+dat.image);
});
});
|
|
|
|
|
Date :
2013-11-29 16:15:16 |
By :
-_-" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|