I recently learn how to code in js and jquery and im confused ,why value of variable a doesn't show? I think it should be 1 or 0 depend on value inside of variable bayar, but why its doesn't work
ive tried to do anything that I can do but it doesn't work like it try to change several code but it doesn't work
heres my controller code
public function generated(){
$data=DB::table("tb_trx_perhitungan_bunga_simpanan")
->selectRaw('trx_bulan')
->get();
return view('crud.form.cobaNampilin',compact('data'));
}
and heres my javascript and jquery code
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var a;
var array = {!! json_encode($data) !!};
var i;
var b;
$('#bulan').keyup(function(){
var bayar=parseInt($('#bulan').val());
for(i=0;i<=array.length;i++){
if(bayar==array[i].trx_bulan){
a=1;
}
else{
a=0;
}
}
$('#hasil').val(a);
});
});
</script>
I expected the output is 1 or 0
strong text
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire