the new DHTML or Ajax : getElementById

Posted under » JavaScript » Ajax on 15 December 2010

Dynamic HTML has livened things up a lot but it has gotten old. These days I hardly use JavaScript functions 'write()', 'writeln().

I heard AJAX is pretty too. What it does is do things in real time by refreshing the page.

Look at his example. Change the data of retail or sale price.



You have saved 50 %

So how is this possible?

Header looks like this

function calculatePercentage (oldval, newval) {
    percentsavings = ((oldval - newval) / oldval) * 100;
    document.getElementById("results").innerHTML = Math.round(percentsavings*100)/100;
}

The contents



You have saved 50 %

Most of the magic is done by the getElementById tag.

web security linux ubuntu GIT svn Raspberry apache mysql php drupal cake symfony javascript Ajax css