Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to save the values of a range slider in the admin of wordpress (with Advanced Custom fields). So far I am receiving the values trough ajax and I can post them with php. Now I want to be able to save them as soon as you push the Update button. The documentation of the range slider is: http://ghusse.github.io/jQRangeSlider/documentation.html This is my code so far:

$("#slider").bind("valuesChanged", function (e, data) {

  $.ajax({
   type: "POST",
   dataType: "text",
   url: "../wp-content/themes/twentytwelve/fields/number_range-v4.php",
   data: { minValue: data.values.min, maxValue: data.values.max },
   async: false,
   success: function(data){


    }
 });
});

</script>

So far so good, it recieves the right values. Then in php, I'm not sure how to do this..:

<?php
    $value = $_POST['minValue'];
}   

function update_value( $value, $post_id, $field )
    {

            ?>
            <script type="text/javascript">$("#slider").editRangeSlider("values", "$value", "$value");</script>
        <?php

            $value = str_replace(',', '', $value);


        // convert to float. This removes any chars
        $value = floatval( $value );


        // convert back to string. This alows decimals to save
        $value = (string) $value;


        return $value;

    }

So I'm trying to save the $value variables to the database along with the post ID. It does not only save the values but also send them back to the slider, so it will be in the right position when a user edits a post. Now I'm not sure how to do this. Any suggestions?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.