Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:41:49+00:00 2026-06-12T06:41:49+00:00

I have a simple select form. When a year is selected from the form

  • 0

I have a simple select form. When a year is selected from the form I would like the results to be returned to the same page but below the form. Can someone explain how to do this? Here is the form page (index.html.erb)

<%= form_tag("lookup/show", :method => "get") do %>
    <%= label_tag(:q, "Pub Year :") %>
    <%= collection_select(:lookup, :pubyear, @pubyears, :pubyear, :pubyear) %>
    <%= submit_tag("Find") %>
<% end %>

Here is the show method from the Lookup controller

def show
    @lookuprows = Lookup.return_lookup_row(params[:lookup][pubyear])

    respond_to do |format|
       format.html
    end
end

Here is the show.html.erb page that the results currently go to

<tbody class="lkuptbody">
    <% @lookuprows.each do |lkup| %>
       <tr class="lkuprow">
         <td><input type="text" class="lkupcode" value=<%= lkup.codetype %> /></td>
         <td><input type="text" class="lkupdesc" value=<%= lkup.codedesc %> /></td>
         <td><input type="text" class="lkuprmks" value=<%= lkup.rermark %> /></td>
       </tr>
</tbody>

I understand that I will have to make a partial _show.html.erb, but how do I reference that from the form page (index.html.erb)?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:41:51+00:00Added an answer on June 12, 2026 at 6:41 am

    If you want the results to appear on the same page but below the form, then the form should send the results to the index action, not to the show action:

    <%= form_tag("lookup", :method => "get") do %>
      <%= label_tag(:q, "Pub Year :") %>
      <%= collection_select(:lookup, :pubyear, @pubyears, :pubyear, :pubyear) %>
      <%= submit_tag("Find") %>
    <% end %>
    

    and in your LookupController:

    def index
      @lookuprows = Lookup.return_lookup_row(params[:lookup][pubyear]) unless params[:lookup].nil?
      ...
    end
    

    Then just append the table HTML in your show page below the form (in index.html.erb) wrapped in an if block to filter out the case where @lookuprows is nil:

    <% if @lookuprows %>
      <tbody class="lkuptbody">
        <% @lookuprows.each do |lkup| %>
          <tr class="lkuprow">
            <td><input type="text" class="lkupcode" value=<%= lkup.codetype %> /></td>
            <td><input type="text" class="lkupdesc" value=<%= lkup.codedesc %> /></td>
            <td><input type="text" class="lkuprmks" value=<%= lkup.rermark %> /></td>
          </tr>
        <% end %>
      </tbody>
    <% end %>
    

    This will show the results in @lookuprows as a table if there are any, if not it will not show the table.

    You may want to put that table HTML in a separate partial to clean up the view, but that is not essential to the problem you asked.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this simple query : SELECT YEAR(P.DateCreated) ,MONTH(P.DateCreated) ,COUNT(*) AS cnt FROM tbl1,
I have a simple form with four select fields. If YES is selected on
I have a simple form for this scenario written in razor/webmatrix. I would like
I have a simple HTML Form with one column having a select menu with
I have a simple dropdown menu: <form class=feedmenu align=center> <select onchange=showRSS1(this.value)> <option value=>Select an
I have written a simple CRUD form which has one select list. However the
I have a simple select from a typed dataset: var productlist = from prds
I have this simple query: SELECT xObjectID, xObjectName FROM dbo.xObject where CONTAINS( xObjectRef, '1838
I have this simple Select box that is suppose to store the selected value
I have a simple html form with select element. To define which option is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.