Ryan Bayne
asked on
Initiate Code - Recalculating Page
I'm trying to learn some code I find advanced. Anyhelp is education LOL
Am I correct in saying that this activates the reCal function?
function init(){
elem = document.forms[0].elements ;
for(var i=0;i<elem.length;i++){
if(elem[i].type=="text"){
elem[i].onkeyup = function(){reCalc(this)};
}
And this is the reCalc function?
function reCalc(theField){
var theForm = theField.form;
if(theField.name.indexOf(" Charge")== 0){
var fldVal = theField.value.replace(/[^ \d\.]/g,"" );
if(fldVal!=theField.value) theField.value = fldVal;
if(theField.name=="ChargeY ear"){
chgDay = fldVal/365;
theForm.ChargeMonth.value = (fldVal/12).toFixed(2);
theForm.ChargeDay.value = (fldVal/365).toFixed(2);
}
OR AM I WRONG?
If you need to see all the code please go here...
http://www.rentacoder.com/RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=276505
Am I correct in saying that this activates the reCal function?
function init(){
elem = document.forms[0].elements
for(var i=0;i<elem.length;i++){
if(elem[i].type=="text"){
elem[i].onkeyup = function(){reCalc(this)};
}
And this is the reCalc function?
function reCalc(theField){
var theForm = theField.form;
if(theField.name.indexOf("
var fldVal = theField.value.replace(/[^
if(fldVal!=theField.value)
if(theField.name=="ChargeY
chgDay = fldVal/365;
theForm.ChargeMonth.value = (fldVal/12).toFixed(2);
theForm.ChargeDay.value = (fldVal/365).toFixed(2);
}
OR AM I WRONG?
If you need to see all the code please go here...
http://www.rentacoder.com/RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=276505
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<:°)