jquery ui slider calculation take value from div and subtract -


looking kind of solution when drag slider take out value total amount. right it's taking out not adding when move slider back. jsfiddle

 function slider1(){ $( "#slider1h1" ).slider({   orientation: "horizontal",   range: "min",   value: 0,   min: 0,   max: 3500000,   step: 50,   slide: function( event, ui ) {     $( "#sliderval" ).val( ui.value );//shows slider value      var asset1 = $('#totalval').val() - $('#sliderval').val();      $('#totalval').val(asset1);//shows total amount   }  }); $( "#sliderval" ).val( $( "#slider1h1" ).slider( "value" ) ); }; 


demo:

html:

amount<input type="text" id="amount" value="35000" /><br/><br/><br/> <br/>  <div class="slidernew"></div> food<input type="text" id="food" value="100" /><br/><br/><br/> <br/> total<input type="text" id="total" /> 

javascript:

$(".slider").slider({     min: 0,     max: 35000,     slide: function(event, ui) { // rule calculation          $( "#amount" ).val( ui.value );         var asset = $('#amount').val() - $('#total').val();         $("#total").val(asset);     } });  $(".slidernew").slider({     min: 0,     max: 100,     value:0,     slide: function(event, ui) { // rule calculation          $( "#food" ).val( ui.value );         var foodval = $( "#food" ).val();         if(foodval != 0){             var food1 = $('#total').val() - (10*foodval);             $('#total').val(food1);         }     } }); 


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -