Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.80/5 (3 votes)
See more:
Hi All,

I have a simple task but don't know enough about java or coding on my website I have an online payment form I want to take the field that is the amount to be paid and add 1% as a surcharge advise the customer and when they accept it then updates the original field with the new amount, Can someone help me with the code of this?
Posted
Comments
Sergey Alexandrovich Kryukov 23-Apr-14 2:01am    
I cannot believe can start programming without knowing multiplication and division. As to understanding percents, I though elementary school is a prerequisite for doing programming.
Read at least something on programming, don't try to solve real problem if you did not do simple exercises.
—SA

i am not sure about java syntax but you can try something like this. its simple maths problem
JavaScript
var newamount = oldamount(origional amount) * 1(this is your percentage)/100;

you need to take care about decimal point precision or sometimes conversion from string to decimal may be.

hope this will help.


[Edit member="Tadit"]
Corrected formatting issues.
Added pre tags.
[/Edit]
 
Share this answer
 
v2
Comments
ravikhoda 23-Apr-14 2:17am    
ps. sorry forget to add one more line

var newamount = oldamount + oldamount(origional amount) * 1(this is your percentage)/100;
Hi,

Try this JavaScript

XML
<script type="text/ecmascript">
        function calculate()
        {
            var onePerc = amount * (percentage/ 100);
            alert(onePerc);
        }
    </script>


GoodLuck
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900