首页 > 解决方案 > 从提交和页面加载后保留范围值

问题描述

我正在研究价格范围滑块。当用户选择价格范围时,我正在提交价格范围滑块更改表格。但是在提交表单并加载页面后,滑块值会被重置。下面是代码 -

 <div class="form-group">
      <div class="price-slider">
           <span><label for="">Price from</label>
           <input readonly name="priceFrom" id="priceFrom" type="number" value="200000" min="200000" max="1000000"/>
           <label for="">Price to</label>
           <input readonly name="priceTo" id="priceTo" type="number" value="1000000" min="200000" max="1000000"/></span>
           <input value="200000" min="200000" max="1000000" step="500" type="range"/>
            <input value="300000" min="300000" max="1000000" step="500" type="range"/>
       </div>
</div>

在价格范围滑块上提交表单的代码是 -

<script>
jQuery(document).ready(function($){
   $('input[type=range]').change(function() {
      $("form#search-form").submit();
   });
});
</script>

在表单提交和页面加载后,有什么方法可以保留用户选择的范围值?任何帮助将不胜感激。谢谢你。

标签: javascriptphpjquery

解决方案


推荐阅读