Ok what I have is a loan enquiry form and when the visitor inputs data into 2 text fields it add the two together and pre-populates another text field
<script type="text/javascript">
$(function () {
var amtreq = $('input:text[id$=amtreq]').keyup(bar);
function bar() {
var loan = amtreq.val();
var percent = (loan / 100 * 2)
sum2 = add2(loan + percent);
$('input:text[id$=totalloan]').val(sum2);
}
function add2() {
var sum2 = 0;
for (var i = 0, j = arguments.length; i < j; i++) {
if (IsNumeric2(arguments[i])) {
sum2 += parseFloat(arguments[i]);
}
}
return sum2;
}
function IsNumeric2(input) {
return (input - 0) == input && input.length > 0;
}
});
However what I am trying to do is to calculate a percentage of the total number
I would like like to calculate 2% of the data in totalsecurity and then to add this value to the value of totalsecurity and then display the result in the textfield with id "totalloan"
** EDIT : noticed I posted wrong bit of code ))
It is calculating the percentage ok now however it doesnt add the 2 together it is simply appending the percent value onto the end of loan value