Initiate Code - Recalculating Page

Posted on 2005-04-29
Last Modified: 2010-04-09
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++){


      elem[i].onkeyup = function(){reCalc(this)};


And this is the reCalc function?

function reCalc(theField){

  var theForm = theField.form;


    var fldVal = theField.value.replace(/[^\d\.]/g,"");

    if(fldVal!=theField.value) theField.value = fldVal;


      chgDay = fldVal/365;

      theForm.ChargeMonth.value = (fldVal/12).toFixed(2);

      theForm.ChargeDay.value = (fldVal/365).toFixed(2);


If you need to see all the code please go here...
Question by:Ryan Bayne
    LVL 30

    Accepted Solution

    > Am I correct in saying that this activates the reCal function?
    Not exactly, it tells the browser to call the reCal function when any of the form elements receive a "keyup" event.
    Note that there is a javascript section for this type of questions:
    LVL 30

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    HTML text in the body of an email (delphi code) 12 52
    jQuery Selector Question 7 37
    Basic CSS issues 24 26
    Javascript - getdate 5 30
    Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
    Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
    In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now