我正在使用 Jquery滑块. script $(function() { $( "#slider-range-max" ).slider({ range: "max", min: %=minprice%, max: %=maxprice%, value: %=minprice%, slide: function( event, ui ) { $( "#amount" ).val( ui.value ); } }); $( "#amount" ).
<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: €</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>
如何获取滑块的值/结果,以便在ASP脚本中使用该值?
这样的事情:console.log($("#slider-range-max").slider('value'));
更多信息:
http://docs.jquery.com/UI/Slider#method-value
从那里你可以轻松地将该值设置为隐藏的输入字段:
<input type="hidden" name="slider_val" id="slider_val" /> <script> var val = $('#slider-range-max').slider('value'); $('#slider_val').val(val); </script>
我现在有这个:
<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: €</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()" />
但是slider_val是空的,出了什么问题?