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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:00:58+00:00 2026-06-12T07:00:58+00:00

I have a simple drop-down menu using HTML’s select tag. The code for the

  • 0

I have a simple drop-down menu using HTML’s select tag. The code for the select tag becomes:

<select name="menu_id" id="menu_id">
  <option selected="selected" value="1">Dinner</option>
  <option value="2">Lunch</option>
</select>

In my menu.js.coffee file I have:

$("select#menu_id").change(-> $(this).closest("form").submit())

This becomes menu.js:

(function() {
  $("select#menu_id").change(function() {
    return $(this).closest("form").submit();
  });
}).call(this);

The problem is changing the select menu doesn’t submit the form! It doesn’t even enter the above menu.js code (I place breakpoints there and it never enters after selecting a menu option).

If I then just copy the inside of the above (function() {, and I paste it into the Firebug or Chrome console, then it runs as expected and changing the menu does in fact submit the form. So how am I supposed to write the coffeescript code in rails to allow forms to be submitted when a select menu is changed?

I’m using Rails 3.2.8.

  • 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-12T07:00:59+00:00Added an answer on June 12, 2026 at 7:00 am

    Try putting your code inside the $(document).ready () -> block.

    $(document).ready () ->
      $("select#menu_id").change(-> $(this).closest("form").submit())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple drop-down menu in PHP: <td> Privilege: </td> <td><select name=privilege>
When I have simple drop down box <select id=fruits> <option value=apple>Apple</option> <option value=orange>Orange</option> <option
I have a simple html option/select (dropdown) menu. I want to use JQuery to
I have a simple drop-down menu that is controlled using the following script: $(document).ready(function
I have a simple dropdown menu: <form class=feedmenu align=center> <select onchange=showRSS1(this.value)> <option value=>Select an
I'm using the jQuery Simple Drop-Down Menu Plugin from http://javascript-array.com/scripts/jquery_simple_drop_down_menu/ In their example, when
I am trying to load a simple select drop down menu from a collection.
I have created a simple drop down menu, with functions in it. And then
Fiddle here: http://jsfiddle.net/emJcx/1/ I have a drop down menu that is a simple show
Currently, I'm using the simple Google Translate drop-down menu found here: http://translate.google.com/translate_tools I'd like

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.