Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function calculate_amt(count,price)
- {
- var ref_amt = document.getElementById("ref_amt").value;
- var total_ref = document.getElementById('total_ref').innerHTML;
- var total = parseInt(Math.round(count * price * 100)/100); //two decimal value
- var balance = 0;
- ref_amt = parseInt(ref_amt);
- if(isNaN(ref_amt))
- {
- ref_amt = 0;
- balance = Math.round(total * 100)/100;
- }
- else
- {
- balance = Math.round((total - ref_amt)* 100)/100;
- }
- if(balance < 0)
- {
- balance = 0;
- }
- if(isNaN(count))
- {
- document.getElementById("quantity").value = '1';
- return;
- }
- if(count == 0)
- {
- document.getElementById("quantity").value = '1';
- return;
- }
- if(ref_amt <= total_ref)
- {
- if(ref_amt > total)
- {
- document.getElementById('ref_amt').value = 0;
- }
- }
- else
- {
- document.getElementById('ref_amt').value = 0;
- }
- document.getElementById("total_amt1").innerHTML=balance;
- document.getElementById("payable_total_amt").innerHTML=balance;
- document.getElementById("AMT").value = balance;
- var data = document.getElementById("CUSTOM").value;
- var cid = data.split(",",1);
- if(count=='') count = 1;
- var cumm = cid+","+count
- document.getElementById("CUSTOM").value='';
- document.getElementById("CUSTOM").value=cumm;
- }
- function calculate_referral(ref_amt,price)
- {
- ref_amt = parseInt(ref_amt);
- var count = document.getElementById('quantity').value;
- var purchase_price;
- var total_ref = document.getElementById('total_ref').innerHTML;
- var total;
- var balance = 0;
- var ref_amt_bal = parseInt(document.getElementById('ref_amt_bal').value);
- if(ref_amt_bal >= ref_amt && parseInt(document.getElementById("total_amt1").innerHTML) >= ref_amt ){
- // Condition to check whether entered amount is with in Original balance & total order
- //alert("success");
- }else{
- alert("Enter applicable refferal amount!"); document.getElementById('ref_amt').value = '';
- document.getElementById('ref_amt').value = 0;
- balance = Math.round(count * price * 100)/100; //two decimal value
- document.getElementById("total_amt1").innerHTML=balance;
- document.getElementById("payable_total_amt").innerHTML=balance;
- document.getElementById("AMT").value = balance;
- var data = document.getElementById("CUSTOM").value;
- var cid = data.split(",",1);
- if(count=='') count = 1;
- var cumm = cid+","+count
- document.getElementById("CUSTOM").value='';
- document.getElementById("CUSTOM").value=cumm;
- return;
- }
- if(isNaN(count))
- {
- document.getElementById("quantity").value = '1';
- return;
- }
- if(count == 0)
- {
- document.getElementById("quantity").value = '1';
- return;
- }
- total = Math.round(count * price * 100)/100; //two decimal value
- if(isNaN(ref_amt))
- {
- ref_amt = 0;
- balance = Math.round(total* 100)/100;
- }
- else
- {
- balance = Math.round((total - ref_amt)* 100)/100;
- }
- if(balance < 0)
- {
- balance = 0;
- }
- if(ref_amt <= total)
- {
- if(ref_amt > total_ref)
- {
- document.getElementById('ref_amt').value = ref_amt;
- }
- }
- else
- {
- document.getElementById('ref_amt').value = 0;
- }
- document.getElementById("total_amt1").innerHTML=balance;
- document.getElementById("payable_total_amt").innerHTML=balance;
- document.getElementById("AMT").value = balance;
- var data = document.getElementById("CUSTOM").value;
- var cid = data.split(",",1);
- if(count=='') count = 1;
- var cumm = cid+","+count
- document.getElementById("CUSTOM").value='';
- document.getElementById("CUSTOM").value=cumm;
- }
- </script>
Add Comment
Please, Sign In to add comment