如何将js变量和php变量相加?

时间:2019-08-10 19:58:08

标签: javascript php

我想对js和php的变量求和。下面是我的代码

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js" /></script>
<script type="text/javascript">
$.fn.fonkTopla = function() {
var toplam = 1;
this.each(function() {
   var deger = fonkDeger($(this).val());

   //get the data attr value
   var diff = $(this).data('diff');
   var paid_val = $(this).closest('tr').find('.paid').val();

   //On based on data attribute, if the input field is paid, do not multiply,
   if(!diff){
   toplam *= deger;

   //take the result minus paid field
   total = toplam - paid_val;
   }
});
return total;
};


function fonkDeger(veri) {
    return (veri != '') ? parseInt(veri) : 1;
}

$(document).ready(function(){
$('input[name^="fiyat"]').bind('keyup', function() {

   //for multiple tr, get the closest tr field value to calculate and display
   $(this).closest('tr').find('.toplam').html( $(this).closest('tr').find('input[name^="fiyat"]').fonkTopla());
});
});
</script>

<td><span class="toplam"></span> RWF</td>

我想显示js的toplam变量+ php的$ credit变量,该变量存储先前的贷方金额。 例子

<td><span class="toplam + <?php $credit;?>"></span> RWF</td>

0 个答案:

没有答案