Rectangle 27 0

javascript How to fetch final value of Jquery UI Slider into PHP Variable ?


This is a site to slider's jquery : http://jqueryui.com/slider/.Try out different sliders and have a look at there codes.Hopefully you will find something of your help.I know its not the best answer you would be expecting but every little help counts when in need.

Note
Rectangle 27 0

javascript How to fetch final value of Jquery UI Slider into PHP Variable ?


$.post("test.php", { $slider_value: $value } );
$value = $("#slider").slider("value"); //or however you get the value

Say you store the slider values as below:

Then you can perform a post call like this:

You could use ajax to pass the slider values to the PHP script.

Note
Rectangle 27 0

javascript How to fetch final value of Jquery UI Slider into PHP Variable ?


<?php
if($_POST && !empty($_POST)){
  $sliders = json_decode($_POST);
  $multipliedValue = $sliders['slider1'] * $sliders['slider2'];
}
var slider1FinalValue = false;
var slider2FinalValue = false;

$( "#slider1" ).slider({
  stop: function( event, ui ) {
    slider1FinalValue = $(this).slider( "value" );
    sendBothValuesIfSet();
  }
});
$( "#slider2" ).slider({
  stop: function( event, ui ) {
    slider1FinalValue = $(this).slider( "value" );
    sendBothValuesIfSet();
  }
});
function sendBothValuesIfSet(){
  if(slider1FinalValue !==false && slider2FinalValue !==false){
    $.post(
        'www.mydomain.com/myscript.php',
        {slider1:slider1FinalValue, slider2:slider2FinalValue }
    );
  }
}

PHP is used to render the page, once the page is rendered php can no longer interact with it. Using jquery you can make an ajax post back to your site with the 2 values something like:

Something along those lines. I havent tested this code just wrote it on the fly so if you have issues let me know and ill adjust it as needed.

Then in your php file:

Note