简体   繁体   English

选择后退按钮上丢失的选项,搜索结果恢复为默认选项

[英]Select Option Lost on Back Button & Search Results Reverts to Default Option

I have a search form on a website for a school, where school staff members can be searched by "First Name" and/or "Last Name". 我在学校的网站上有一张搜索表,可以通过“名字”和/或“姓氏”搜索学校工作人员。 Search can be narrowed down by "Type of Staff" 可以通过“职员类型”来缩小搜索范围

The default search is "Teachers", as that is the most popular term and common search performed. 默认搜索为“教师”,因为这是最受欢迎的术语和执行的常见搜索。

All other school staff listings are hidden, unless user selects them via the drop down menu ( select & option ). 除非用户通过下拉菜单(select&option)将其选中,否则所有其他学校职员列表都是隐藏的。

The problem is that if the user is looking for a "Daycare Staff member", clicks on one of the "Daycare Staff" to view her profile, then click the "back button", the default "Teachers" option is selected again and the previous option "Daycare Staff" is lost. 问题是,如果用户正在寻找“日托人员”,请单击其中一个“日托人员”以查看其个人资料,然后单击“后退按钮”,再次选择默认的“教师”选项,然后以前的选项“日托人员”丢失了。

My question is, if I have to use cookies, how do I use cookies to not reset to the default search option. 我的问题是,如果必须使用cookie,如何使用cookie而不重置为默认搜索选项。

Is there another way, besides using cookies? 除了使用Cookie,还有其他方法吗?

Here is an example of what the code of search form looks like: 这是搜索表单代码的示例:

<form class="form-inline" action="#">
    <div class="form-group">
        <input type="text" class="form-control" id="id_search_first" placeholder="Search by First Name">
    </div>
    <div class="form-group">
        <input type="text" class="form-control" id="id_search_last" placeholder="Search by Last Name">
    </div>
    <div class="form-group">
        <select id="group" class="form-control">
              <option value="">Groups</option>
              <option value="Principle">Principle</option>
              <option value="Vice Principle">Vice Principle</option>                                                              
              <option value="Teachers" selected="selected">Teachers</option>              
              <option value="Daycare Staff">Daycare Staff</option>
              <option value="Educational Assistants">Educational Assistants</option>                                                              
              <option value="Special Needs Assistant">Special Needs Assistant</option>                                                            
              <option value="Human Resources">Human Resources</option>
              <option value="Day Time Caretaker">Day Time Caretaker</option>
              <option value="Night Time Caretakers">Night Time Caretakers</option>  
              <option value="School Administration">School Administration Staff</option>                                                              
        </select>                                                                                                           
        <div class="default"><input type="text" style="" class="form-control ShowTeachers" id="schoolTeachers" value="Teachers"></div>
    </div>
</form>

Thanks! 谢谢!

尝试将选定的组值保留在$ _SESSION中并从会话中更新组值,则即使用户返回时,选定的值仍保持不变。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM