How do I create a calculator?

Associate
Joined
3 Aug 2004
Posts
1,614
Location
Bendigo, Australia.
I would like to implement fairly simple calculator on a website that will calculate the area of a garden and multiply it by one or four prices.

I really don't have a clue where to start. Any help appreciated.
 
Thanks for that.

:) Unfortunately, you lost me at "create 2 php variables". I am familiar with Wordpress and given my absence of any coding skills, it's probably a good thing the site uses it.

I sent you an email.
 
If I knew enough about it I would :p

Creating a wordpress plugin seems to be beyond my skill.

No matter what I try, it just shows the HTML above the page and messes everything up. Tried it in a page and installed a plugin that allows PHP in the post, it kind of works but echo's the answer to a blank screen and not the wordpress page.

I'll keep playing for you OP, but I may not be able to do it.

I appreciate your efforts.

I have seen dozens of calculators of varying degrees of complexity, on similar turf/garden related websites but view source may as well be in Aramaic.


<script>

function updateQuote(area){

var area = parseInt(document.getElementById('gardenArea').value);
var pricePlan = parseInt(document.getElementById('priceOption').value);

var quote = area * pricePlan;
document.getElementById('quoteResult').innerHTML = quote;

}

</script>

Garden Area: <input type="text" name="gardenArea" id="gardenArea" onKeyUp="updateQuote();" style="width:40px;"> (square meters),
Price Plan:
<select name="priceOption" id="priceOption" onChange="updateQuote();">
<option value="10">Cheapest</option>
<option value="20">Cheap</option>
<option value="30">Expensive</option>
<option value="40">Most Expensive</option>
</select>
<br/>
Quote: &pound;<span id="quoteResult">0</span>

Thanks for the suggestion. Unfortunately, I get four individual drop-down boxes which don't seem to influence or effect any calculation when chosen.
 
Last edited:
Back
Top Bottom