EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: cekone on January 05, 2017, 09:43:32 AM



Title: The sum of two numberbox
Post by: cekone on January 05, 2017, 09:43:32 AM
Please help stworthy, I want to sum from two to one numberbox in the form..

Code:
<fieldset id="fieldset">
       <div align="center" class="ftitle">Isi Form Pelanggan Baru</div>
            <form id="fm" method="post" novalidate>
                    <tr>
                        <td class="fitem">
                            <input id="tagihan_bln" name="tagihan_bln" class="easyui-numberbox" formatter="rupiah"   style="width:250px;height:30px;text-align:right" data-options="label:'Tagihan :',precision:0,groupSeparator:','" required="true"></td>
                        <td class="fitem">
                            <input id="potongan" name="potongan" class="easyui-numberbox" formatter="rupiah" style="width:250px;height:30px;text-align:right" data-options="label:'Fee :',precision:0,groupSeparator:','" required="true"></td>
                        <td class="fitem">
                            <input id="tagihan_sisa" name="tagihan_sisa" class="easyui-numberbox" formatter="rupiah" style="width:250px;height:30px;text-align:right" data-options="label:'Sisa :',precision:0,groupSeparator:','" onChange="true" readonly="true"></td>
                    </tr>
            </form>
</fieldset>

//code
$('#fm').form('load');
        var a = $('#tagihan_bln').numberbox('getValue');
        var b = $('#potongan').numberbox('getValue');
        var sum = a.numberbox('getValue')-b.numberbox('getValue');
        $('#tagihan_sisa').numberbox('setValue',sum);


Title: Re: The sum of two numberbox
Post by: gunmo on January 05, 2017, 07:27:53 PM
well,a is already the value of the first numberbox,and b is the value of the second numberbox.You needn't to get value again when you sum.
Code:
var sum = a - b;


Title: Re: The sum of two numberbox
Post by: cekone on January 05, 2017, 10:29:53 PM
ok, that's the way I tried, but it still does not work. value can not be contained in var a and var b.


Title: Re: The sum of two numberbox
Post by: gunmo on January 05, 2017, 11:39:44 PM
Do you have write a method to excute these code?You can also write a method  on "onchange" event.