开发者

JQUERY Slider get value

开发者 https://www.devze.com 2023-02-12 20:50 出处:网络
I\'m using the Jquery slider. <script> $(function() { $( \"#slider-range-max\" ).slider({ range: \"max\",

I'm using the Jquery slider.

<script>
    $(function() {
        $( "#slider-range-max" ).slider({
            range: "max",
            min: <%=minprice%>,
            max: <%=maxprice%>,
            value: <%=minprice%>,
            slide: function( event, ui ) {
                $( "#amount" ).val( ui.value );
            }
        });
        $( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) );
    });
</script>
<div class="demo">
    <label 开发者_开发问答for="amount">Selecteer uw maximum prijs: &euro;</label>
    <input type="text" id="amount" name="maxprijs" style="border:0; color:#f6931f; font-size:14px; font-weight:bold;" />
<div id="slider-range-max"></div>

</div>

How can I get the value/result of the slider so I can use that value in my ASP script?


something like this:

console.log($("#slider-range-max").slider('value'));

More info:

http://docs.jquery.com/UI/Slider#method-value

From there you could easily set that value to a hidden input field:

<input type="hidden" name="slider_val" id="slider_val" />

<script>
    var val = $('#slider-range-max').slider('value');

    $('#slider_val').val(val);
</script>

I've got this right now:

<script>
    $(function() {
        $( "#slider-range-max" ).slider({
            range: "max",
            min: <%=minprice%>,
            max: <%=maxprice%>,
            value: <%=minprice%>,
            slide: function( event, ui ) {
                $( "#amount" ).val( ui.value );
            }
        });
        $( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) );
    });

</script>
<div class="demo">
    <label for="amount">Selecteer uw maximum prijs: &euro;</label>
    <input type="text" id="amount" name="maxprijs" style="border:0; color:#f6931f; font-size:14px; font-weight:bold;" />
<div id="slider-range-max"></div>

</div>
<script>     
var val = $('#slider-range-max').slider('value');      
$('#slider_val').val(val); 
</script> 
    <form name="priceSearch" method="post" action="sanitair.asp">
    <input type="hidden" name="act" value="price" />
    <input type="hidden" name="slider_val" id="slider_val" />  
    <input type="button" class="infoButton" value="Sorteren" onclick="searchpr()" />

But slider_val is empty, what's going wrong?

0

精彩评论

暂无评论...
验证码 换一张
取 消