Ok, I have these input boxes.
<input
type="text"
name="amount"
class="validate[required] text-input"
id="amount">
<input type="text"
name="incfee"
id="incfee"
readonly>
And this is the javascript I have :-
<script type="text/javascript">
window.onload = function() {
var amount = document.getElementById('amount');
var incfee = document.getElementById('incfee');
var fee = 0.01;
amount.onkeyup = function() {
var result = parseFloat(amount.value) * fee;
// var result1 = result + amount;
incfee.value = !isNaN(result) ? result : '';
};
}
</script>
Now, the problem is, that if I comment the line "var result1 = result + amount;" and rename result1 to result in incfee.value , the value of the textbox (amount including fee) changes with the value in amount and everything works fine.
BUT, If I uncomment the line var result1 = result + amount; and change result to result 1 in incfee.value, the javascript doesn't works and no value is populated in the incfee textbox.
What mistake am I doing?
Thanks.