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 8512337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:15:10+00:00 2026-06-11T04:15:10+00:00

I have dropdown list using select_tag and I have button near it. I have

  • 0

I have dropdown list using select_tag and I have button near it.

I have following requirements:
1) on click of submit button it should go to books#show action
2) Then in show action I retrieve the selected book from dropdown list
3) The show method should show details of book that I would retrieve from database
i.e,the same page should update with this book details.

However,I am unable to perform none of this.

In my view:

<%=  form_tag books_path do |f|%>
<%= label_tag "select book" %>
<%= select_tag "selectbook", options_from_collection_for_select(@bid,"book_id","book_id"), :prompt => "Select book",:class => 'cmbbook' %>
<%=  submit_tag "view ...", :disable_with => "Please wait." ,:action => "show"%>
<%end%>

In my controller

if(params[:selectbook])
      @books =  Book.where("book_id = ?",params[:selectbook])
else
      @books = Book.all
end
@bid= Books.select("book_id").uniq;

respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @books }
      format.json { render json: @books }
end

The submit method calling action create instead of show and I also wish the page autoupdate with new book data.

  • 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-11T04:15:12+00:00Added an answer on June 11, 2026 at 4:15 am

    I have found what to do:

    I have to write a method in javascript that calls getJson() method to appropriate controller and action and again update view using javascript.Thus,using ajax javascript problem is solved.However,I wish I can do same with pure ruby code.

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

Sidebar

Related Questions

I have a dropdown list. I am using onchange event of this dropdown to
Basically, I have populated a dropdown list using php from a database on a
I'm using Jquery 1.6. I have a dropdown list that has a bunch of
I am using Spring Web MVC for my application. I have 1 dropdown list
I have a nested dropdown list created using the latest version of Twitter BootStrap.
The dropdown-menu (built by the select_tag) in my application should call the filter-category-action as
I have a dropdown country list using the jquery and stuff at http://jsfiddle.net/josh3736/jf5QK/ however
I have the following dropdown list: <select name=DD1 id=DD1> <option value=B>B</option> <option value=D>D</option> <option
I have a dropdown list which has items bound to it using sql datasource.
i have the following code where i have a dropdown list (with class= addToList

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.