Is there a way to calculate a figure and show the result in HTML5 without using forms?


I am not a huge fan of Javascript so prefer to do as much as possible with HTML/CSS, probably to my disadvantage.

So my question is could I for example display one number 1.00 and then do a calculation on it eg (times it by 85) and show the output in HTML5? (Without using forms?).

I have seen examples that use inputs, but I don't really need user input, I just want it to do a calculation on load.

If you see one of my pages below, you will see that there are a list of prices and I want to convert them all to a different currency (I don't need to get the currency rate (I can add that manually, just want it to do the basic calculation eg : 100 rupees = 0.95 pounds Calulation (100*0.95) Returns £0.95p

For example :

Cost Of living in India example

So I just want to input the current exchange rate in one place and it will calulate the £ rates for each entry in the list.

If this can't be done in HTML5, can someone suggest the bare minimum javascript to do the same?

Problem courtesy of: Poiple Shadow


Use following simple JavaScript.

Create a new <script> tag in the head section as follows with some variable name.

    var exchange_rate = .95;

Where ever you want to do calculations use as following

    Cost of Cooking : 
        document.write(exchange_rate * 100);

So, if you change the exchange_rate in the head section's <script> tag, it will show proper values wherever you used it.

Solution courtesy of: Vanga Sasidhar



    <span id="costofliving">1.00</span>


var cost = document.getElementById('costofliving');

function calculate() {
    cost.innerText = Number(cost.innerText) * 85;

// will be set in 2 seconds
setTimeout(calculate, 2000);

See it here:

Discussion courtesy of: wilmoore

This recipe can be found in it's original form on Stack Over Flow.