duanhe1976 2017-04-17 07:49
浏览 29
已采纳

从没有页面加载的下拉列表中获取选定的值

I have a page with multiple filters to search data from Database. It has a view limit dropdown at the end of the page that is out of the main search form. View limit asks the user how many records does he want on a single page. when user selects the record limit, ajax loads the results with selected limit, now when the user (who is on page 1) clicks the next page button to see recrods on page 2 the view limit dropdown resets itself to default value, for example if there are 60 products for his search and he selected 20 record per page on page 1, when he goes to page 2 the view limit dropdown will show 10 instead of 20 on next page in view limit dropdown. I want the view limit value on next page that he selected on first page i.e 10.

<div class="view-limit">
                View:&nbsp; <select name="view-limit" id="view-limit" class="form-control" style="display:inline-block;">
                    <option value="10">10</option>
                    <option value="20">20</option>
                    <option value="30">30</option>
                    <option value="50">50</option>
                    <option value="100">100</option>
                </select>
            </div>

This is my view limit html, I dont want to include it in the form and send this data with the search filters. Is there any way that I can send this data to next page without form submission? I tried to send it using a variable in URL but i cant get the value of view limit in a variable until any request is sent to the server.

  • 写回答

2条回答 默认 最新

  • douzhang8144 2017-04-17 10:05
    关注

    I figured out the way to pass variable to next page through URL Here is how i did it:

    $(document).on("click","#pager",function(e) {
        e.preventDefault();
        location.href = this.href +'?view='+ escape($('#view-limit').val());
        return false;
    });
    

    pager is the id for the link htat is clicked when user wants to go to next page

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵