38 lines
1.6 KiB
PHP
38 lines
1.6 KiB
PHP
<?php
|
|
include ('../../koneksi.php');
|
|
$id=$_POST['id'];
|
|
$data=pg_query("SELECT * FROM sp_bbm WHERE id='$id'");
|
|
while($row=pg_fetch_array($data)) {
|
|
$id=$row['id'];
|
|
$nama=$row['nama'];
|
|
$harga=$row['harga'];
|
|
}
|
|
?>
|
|
|
|
|
|
<form role="form">
|
|
<div class="form-group">
|
|
<label for="exampleInputEmail1">Nama</label>
|
|
<input type="hidden" value="<?php echo $id; ?>" id="bbm_id">
|
|
<input type="text" class="form-control" value="<?php echo $nama; ?>" id="nama_bbm">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="exampleInputEmail1">Harga</label>
|
|
<input type="text" class="form-control" onkeyup="formatAngka(this,'.')" value="<?php echo number_format($harga,0,',','.'); ?>" id="harga_bbm">
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
function formatAngka(objek, separator) {
|
|
a = objek.value;b = a.replace(/[^\d]/g,"");c="";panjang=b.length;j=0;
|
|
for(i=panjang;i>0;i--) {j=j+1;if(((j%3)==1)&&(j!=1)) {c=b.substr(i-1,1)+separator+c;} else {c=b.substr(i-1,1)+c;}}objek.value=c;
|
|
}
|
|
|
|
function hanyaAngka(evt) {
|
|
var charCode = (evt.which) ? evt.which : event.keyCode
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
|
return false;
|
|
return true;
|
|
}
|
|
</script>
|