/    Sign up×
Community /Pin to ProfileBookmark

How to make/find a price calculator?

I’m experimenting with ideas for a future website and I want something similar to this screenshot:

[URL=”http://screencast.com/t/ADfZZlv9″]http://screencast.com/t/ADfZZlv9[/URL]

The calculator:
I am thinking of making the numbers rise to the prise tag instead of just showing it. It must have addition and subtraction abilities, as well as listing selected products in two places – one for overview and one for e-mail.

Does anyone have good experience with this sort of coding, or is there a company doing this for a living and licencing their stuff?

I have almost no experience in coding javascript myself.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJul 22.2013 — This example does not replicate your display, but it will act as a starting point for what you want to do.
<i>
</i>&lt;!doctype html&gt;
&lt;html&gt;
&lt;meta charset="utf-8" /&gt;
&lt;title&gt; Checkbox Summation &lt;/title&gt;
&lt;style type="text/css"&gt;
.cbValue { }
&lt;/style&gt;
&lt;body&gt;

&lt;div id="CostBox"&gt;
&lt;input type="checkbox" class="cbValue" value="9.99" onclick="UpdateCost()"&gt;Product 1 ( 9.99)&lt;br&gt;
&lt;input type="checkbox" class="cbValue" value="19.99" onclick="UpdateCost()"&gt;Product 2 (19.99)&lt;br&gt;
&lt;input type="checkbox" class="cbValue" value="27.50" onclick="UpdateCost()"&gt;Product 3 (27.50)&lt;br&gt;
&lt;input type="checkbox" class="cbValue" value="45.65" onclick="UpdateCost()"&gt;Product 4 (45.65)&lt;br&gt;
&lt;input type="checkbox" class="cbValue" value="87.20" onclick="UpdateCost()"&gt;Product 5 (87.20)&lt;br&gt;
&lt;input type="text" id="totalcost" value="" size="6"&gt; Total ($)
&lt;/div&gt;

&lt;script type="text/javascript"&gt;

function UpdateCost() {
var sum = 0;
var sel = document.getElementById('CostBox').getElementsByClassName('cbValue');
for (i=0; i&lt;sel.length; i++) {
if (sel[i].checked) { sum += Number(sel[i].value); }
}
document.getElementById('totalcost').value = sum.toFixed(2);
}


&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

Good Luck!
Copy linkTweet thisAlerts:
@hrrubinauthorAug 10.2013 — Thank you.
×

Success!

Help @hrrubin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...