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

  • Home
  • SEARCH
  • 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 pass a class-instace to a method of an other and be sure
I want to pass a few variables to another page. Currently I'm using response.redirect
i want to pass large variables to a PHP script on another server with
I want to pass a variable to he buttonEvent method in the selector. [button
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 an array of arbitrary struct pointers and a comparison function
I want to pass data between a Python and a C# application in Windows
I want to pass through configuration arguments to a class. These are all the
I want to pass around some values in an array that will always be

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.