echo1990Avatar border
TS
echo1990
Logika menghitung otamatis langsung format angka denga javascript
Pertama kita harus membuat blabla.js
dan koding ny :


function startCalc_operator()
{interval=setInterval("calc()",1)}
function calc_operator()
{satu=document.f.sikokBox.value;
haha=document.f.hahaBox.value;
dua=document.f.duoBox.value;
tiga=document.f.tigoBox.value;
empat=document.f.ampatBox.value;
wkwk=document.f.wkwkBox.value;

document.f.loloBox.value=(satu*1)+(haha*1)

lolo=document.f.loloBox.value;

if(satu)
{
document.f.jumlaBox.value=(lolo*1)/(dua*1)*(tiga*1)
}
else
{
document.f.jumlaBox.value = '';
}


dua=document.f.duoBox.value;
if(satu)
{
document.f.limoBox.value=(dua*1)-(lolo*1);
formatangka(document.f.limoBox);
}
else
{
document.f.limoBox.value = '';
}

wkwk=document.f.wkwkBox.value;
if(lolo)
{
document.f.nilaiBox.value=(wkwk*1)-(lolo*1);
formatangka(document.f.nilaiBox);
}
else
{
document.f.nilaiBox.value = '';
}

}
function stopCalc_operator(){clearInterval(interval)}

Lalu membuat format angka , misal angka.js:

function replaceChars_operator(entry) {
out = "."; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.f.duoBox.value = temp;
}

function replaceChars_operator1(entry) {
out = "."; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.f.sikokBox.value = temp;
}

function replaceChars_haha(entry) {
out = "."; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.f.hahaBox.value = temp;
}


function trimNumber_operator(s) {
while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,9999); }
while (s.substr(0,1) == '.' && s.length>1) { s = s.substr(1,9999); }
return s;
}

function formatangka_operator(objek) {
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) + "." + c;
} else {
c = b.substr(i-1,1) + c;
}
}
objek.value = trimNumber(c);
}

Lalu buatlah form pada php:
blabla.php


<label class="control-label col-md-3">Dana Pendamping</label>
<div class="col-md-9">
<input type="text" class="form-control" required="required" name="pendamping">
<input type="hidden" class="form-control" name="hahaBox">
<input type="hidden" class="form-control" name="loloBox">
</div>

<label class="control-label col-md-3">Realisasi Keuangan</label>
<div class="col-md-9">
<input type="text" class="form-control" name="b">
<input type="hidden" class="form-control" name="satuBox">
<input type="hidden" class="form-control" name="tigaBox" value="100">
</div>

<div class="form-group">
<label class="control-label col-md-3">Persentase Keuangan</label>
<div class="col-md-9">
<input type="text" class="form-control" name="jumlahBox" readonly="">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Persentase Fisik</label>
<div class="col-md-9">
<input type="text" class="form-control" required="required" name="fisik">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Sisa Dana SKPD </label>
<div class="col-md-9">
<input type="text" class="form-control" name="thirdBox">
<input type="hidden" class="form-control" name="operator">
</div>
</div>


Selebihnya kembangin sendiri gan. Sorry codingnya rada membinggungkan:
emoticon-Kiss
emoticon-Belokissemoticon-I Love Indonesia (S)emoticon-I Love Indonesia (S)emoticon-I Love Indonesia (S)emoticon-I Love Indonesia (S)emoticon-Belomatabeloemoticon-Matabelo
Diubah oleh echo1990 25-05-2014 18:46
0
2.3K
2
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Urutan
Terbaru
Terlama
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Komunitas Pilihan