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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:53:37+00:00 2026-05-19T21:53:37+00:00

Rails 2.3.5, Ruby 1.86 I haven’t been able to figure this out. The ‘onchange’

  • 0

Rails 2.3.5, Ruby 1.86

I haven’t been able to figure this out. The ‘onchange’ in the select below is not being written (no onchange written in the HTML). I haven’t seen a reference to the syntax being different except in some older examples the onchange is surrounded in brackets:

<%= f.select :directory_id, options_for_select(@directories, @directory_to_select), :onchange => 'folder_lookup()' %>

results in:

<select id="contact_directory_id" name="contact[directory_id]">
<option value="2">test_1</option>
<option value="4">test_2</option>
<option value="33" selected="selected">test_3</option>
</select>

If I simply change “f.select” to “select_tag” the onchange is written correctly (not that I want to do that though):

<%= select_tag :directory_id, options_for_select(@directories, @directory_to_select), :onchange => 'folder_lookup()' %>

results in:

<select id="contact_directory_id" name="directory_id" onchange="folder_lookup()">
<option value="2">test_1</option>
<option value="4">test_2</option>
<option value="33" selected="selected">test_2</option>
</select>

Am I missing a syntax difference for onchange between a select and select_tag helper?

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-05-19T21:53:38+00:00Added an answer on May 19, 2026 at 9:53 pm

    This is what you want:

    <%= f.select :directory_id, options_for_select(@directories, @directory_to_select), {}, :onchange => 'folder_lookup()' %>
    

    With select the method signature looks like this select(object, method, choices, options = {}, html_options = {}). onchange is an html_option, since you don’t have any options, you need an empty hash so that your last onchange is taken as an html_option.

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

Sidebar

Related Questions

I'm trying initialize my local rails server but I haven't been able to, because
Now, I haven't been able to find any good resources on this subject so
A specific page for my ruby on rails website is slow. To figure out
I'm new to Ruby on Rails and I'm sure this question is pretty stupid,
I haven't touched Ruby/Rails for about a year now and need a quick reminder:
I'm relatively new to Ruby on Rails and occasionally I find this convention-over-configuration stuff
I have been using ActiveResource in my Ruby on Rails applications for some time,
I haven't been able to find a very good way of getting 10 random
This question pertains to Ruby on Rails and PHP. When looking for a VPS
I have been creating a website with Ruby on Rails, and will be hosting

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.