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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:03:24+00:00 2026-05-26T02:03:24+00:00

I want to pass collection_select a value with the link_to_remote method. When I did

  • 0

I want to pass collection_select a value with the link_to_remote method. When I did this, I got an internal server error. I am using Rails 2.3.8. My code:

 <%= collection_select("event", "trainer_id", @trainers , :id, :name, {:prompt => 'Select a Trainer'}, {:onchange=> "#{link_to_remote(:url => {:controller => 'events', :action => 'find_new' }, :with=>"'trainer_id='+value")}"}) %>

Added

This my controller code:

def find_new
@trainers= Trainer.all
if ["0"].include?(params[:trainer_id])
    render :partial=>'events/me'
    else
    render :partial=> 'events/something'
    end
end
  • 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-05-26T02:03:25+00:00Added an answer on May 26, 2026 at 2:03 am

    onchange will expect javascript, you’re providing an HTML a element with your link_to_remote.

    I’m guessing you’d want to redirect the user to the page you selected?

    <%= collection_select("event", "trainer_id", @trainers , :id, :name, {:prompt => 'Select a Trainer'}, {:onchange=> "redirectToTrainer(this.value)"}) %>
    
    <%= javascript_tag do %>
      function redirectToTrainer(trainerId){
         window.location = "<%= url_for(:controller => 'events', :action => 'find_new') %>?" + trainerId;
      } 
    <% end %>
    

    There are cleaner ways to do this, Unobtrusive Javascript for one, but I think that’s what you’re looking for.

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

Sidebar

Related Questions

I want to pass data from client side to server-side. I am using jQuery
I want to pass an IEnumerable collection from view to controller using JQuery from
I want pass a class-instace to a method of an other and be sure
i want to pass the value of a datetimepicker to my Codebehind(C#) and save
I want to pass value of i as a parameter for autosuggest. My intention
I have Backbone.js collection that holds (for example) 30 items. I want to pass
Given a .net 4. collection, if I want to pass in my own custom
I want to pass the id from one action to the next action, but
I want to pass id from view to controller. I know how to pass
I want to pass a custom object from one Activity to another, here 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.