简体   繁体   English

后退按钮Javascript问题

[英]Back button Javascript issue

So I have a page where I am making selections using option buttons, Those selections show up as a value. 因此,我在一个页面上使用选项按钮进行选择,这些选择显示为一个值。 There are options which are selected as default using Javascript as per the code below. 根据以下代码,使用Javascript将某些选项选为默认选项。

Now on hitting Proceed I go to the next page. 现在点击继续,进入下一页。 Now on the next page I have a back button and when I press the back button, What I want is the selections which I had made on the previous page should remain the same, What is happening on the other hand is, the default selected options are showing up. 现在在下一页上,我有一个后退按钮,当我按下后退按钮时,我想要的是我在上一页所做的选择应该保持不变,另一方面,发生的是默认选择的选项出现。

I am using this button for the moment: 我目前正在使用此按钮:

<input type="button" value="Back" onclick="window.history.back()" /> 

And this is how I am doing the selection: 这就是我所做的选择:

<div class="panel panel-default">
    <div class="panel-heading">
     <h2 class="panel-title" id="selected_part_<%= part.id %>">


      <% @link_text =  "<b>#{part.name}</b> : <span class='selected_part_option'>#{part.options.detect{|o| o.is_default?}.try(:name)}</span>" %>

      <% if part.children.exists? %>
      <% part.children.each do |part_child| %>
      <% if part_child.display_type == "radio" || part_child.display_type == "dropdown" %> 
      <%# @link_text = @link_text + " | <span id='part_child_" + part_child.id.to_s + "'>" + part_child.options.first.name + "</span>" %>
      <% end %>
      <% end %>
      <% end %>
      <%= link_to raw(@link_text), "#collapse_part_#{part.id}", class: "collapser", "data-toggle" => "collapse", "data-parent" => "#accordion" %>
    </h2>
  </div>

Any idea how do I achieve what I want to? 知道如何实现自己想要的目标吗? Thanks in advance. 提前致谢。

The default behaviour of Firefox browser is to remember the form's input value. Firefox浏览器的默认行为是记住表单的输入值。 I think in your case, you may use some JavaScript which reset the form automatically, which makes lost the state that the browser remembered. 我认为在您的情况下,您可以使用一些JavaScript来自动重置表单,从而丢失浏览器记忆的状态。

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

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