Greetings! I am at a loss of why this is happening and hopefully someone can give me a bit of insight. I am creating an html form to be used in a mainframe. All validation on the form has to be done in javascript. So, I have this function:
Code:
function getTotalPayoffAmount() {

var j_PayoffTotalRef = document.getElementById('txtPayoffTotal');
j_PayoffTotalRef.value = '';
var j_currentPrincipalBalanceRef = document.getElementById('txtCurrentPrincipalBalance');
var j_accruedInterestRef = document.getElementById('txtAccruedInterest');
var j_currentPrincipalBalanceVal = j_currentPrincipalBalanceRef.value;
var j_accruedInterestVal = j_accruedInterestRef.value;
j_currentPrincipalBalanceVal = parseFloat(j_currentPrincipalBalanceVal.replace(/[^0-9-.]/g, ''));
var j_totalPayoffAmount = j_currentPrincipalBalanceVal + j_accruedInterestVal
j_PayoffTotalRef.value = formatCurrency(j_totalPayoffAmount);
}
There are a lot more variables but my problem is that I have other functions that I created that could use these variables but when I move them out of the function and paste them in between the <script> tags, I get an object is expected error. I copy the varaiables back into the function and boom...it works again...why?!

may be a silly question but it doesn't make sense to me, I'm just creating a reference to an textbox and it's value, so why can't I do that outside of a function and then call those variables from within the function??