Skip to content

Instantly share code, notes, and snippets.

Created Apr 14, 2016
What would you like to do?
math tool
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="">
<!--<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>-->
a:<input id="a" value="56.5" /><div id="s-a" class="slider"></div><br>
b:<input id="b" value="56.5" /><div id="s-b" class="slider"></div><br>
c:<input id="c" value="56.5" /><div id="s-c" class="slider"></div><br>
d:<input id="d" value="56.5" /><div id="s-d" class="slider"></div><br>
e:<input id="e" value="56.5" /><div id="s-e" class="slider"></div><br>
f:<input id="f" value="56.5" /><div id="s-f" class="slider"></div><br>
g:<input id="g" value="56.5" /><div id="s-g" class="slider"></div><br>
h:<input id="h" value="56.5" /><div id="s-h" class="slider"></div><br>
<p><b>a*0.02+b*0.07+c*0.11+d*0.28+e*1.12+f*2.24+g*3.36+h*4.48=</b><span id="result1"></span> (452)</p>
<p><b>a+b+c+d+e+f+g+h=</b><span id="result2"></span> (452)</p>
var v = {};
$(function () {
function calc() {
// get all var
$("input").each(function (key, val) {
v[] = Number($(this).val());
// calc
var result1 = v.a*0.02+v.b*0.07+v.c*0.11+v.d*0.28+v.e*1.12+v.f*2.24+v.g*3.36+v.h*4.48,
result2 = v.a+v.b+v.c+v.d+v.e+v.f+v.g+v.h;
// set result
$("input").on("change", function () {
$( ".slider" ).slider({
min: 30,
max: 100,
step: 1,
slide: function( event, ui ) {
$("#" +"s-", "")).val( ui.value );
//$( "#amount" ).val( "$" + $( "#slider" ).slider( "value" ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment