Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Actually this is my view am getting values from mysql database and i showed in browser based on the params page=1 page =2 page =3 and i want to change the params[:page] in form next button click.

Based on pages=1,2,3 questions and answers will vary thats why i need url to be change while button click in same page.! like below URL http://localhost:3000/responses/new?page=1 Thanks in advance.

<%= form_for (@response)  do |f| %>
    <% @questions.each do |pgquestion| %>
        <% if pgquestion.group_id == 0 %>
            <%= label :pgquest,pgquestion.description %><br><br>
        <% else %>

            <%= label :pgquest,pgquestion.description %> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <% (1..pgquestion.question_value.to_i).each do |i| %>
                <%= radio_button_tag "ans_value[#{ pgquestion.quest_id }]", i %>
            <% end %>
            <br><br>
            <% if pgquestion.question_type == "textarea" %>

                <%= text_area "", "ans_value[#{ pgquestion.quest_id }]" ,size: '80x5'  %><br><br>
            <% else if pgquestion.question_type == "text" %>
                    <%= text_field "", "ans_value[#{ pgquestion.quest_id }]"  %>   <br><br>

            <% end %>

            <% end %>

        <% end %>

    <% end %>
      <div style="text-align: center">
    <%= f.submit 'Prev' ,:class => 'btn btn-primary',:name => "previous_button" %>
    <%= f.submit 'Next', :class => 'btn btn-primary' %> <br><br>

        <p><%= f.submit "Continue" %></p>
        <p><%= f.submit "Back", :name => "previous_button" %></p>

      </div>

<% end %>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
158 views
Welcome To Ask or Share your Answers For Others

1 Answer

As far as i understand your problem use the will_paginate gem https://github.com/mislav/will_paginate


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...