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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:29:52+00:00 2026-05-25T00:29:52+00:00

I am new to RoR and I am looking for a way to dynamically

  • 0

I am new to RoR and I am looking for a way to dynamically display values in some text fields depending on the option chosen from a select menu in a form. The associated records are stored in another table. Hopefully in a way AJAX can be used such that it wouldn’t require a page refresh. I have seen examples in which select menus are dynamically changed according to values of select menus but not text fields.
Thanks,
Alex
PS: I am using rails 3.

  • 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-25T00:29:53+00:00Added an answer on May 25, 2026 at 12:29 am

    Here’s how I did it. I’m a Rails beginner too, so this may not be the best/most efficient way, but it works:

    JS:

     $('#select_box_id').live('change', function() {
        var select_field_val = $('#select_box_id').val();
        if(select_field_val == "") select_field_val = "0";
        $.get('/some_controller_action/' + select_field_val, function(data) {
          $('#text_field_div').html(data);
        });
        return false;
      });
    

    Controller:

      def some_controller_action
        #some_processing...
        result = whatever
        render :partial => "my_partial", :locals => { :text_field_value => result }
      end
    

    View:

    <div id="text_field_div">
       <%= render :partial => 'my_partial', :locals => { :text_field_value => "" } %>
    </div>
    

    Partial:

    <%= text_field_tag :text_field, text_field_value %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for a way to either: Change one of the fields of a new
New Question I am looking for a way in Javascript to get the parent
I'm new to RoR coming from django, RoR is not as easy as django
I'm pretty new to RoR programming. I remember reading on some tutorial (forgot which)
I come from a PHP and Python/GAE background and am new to RoR. Typically
Am new to RoR paperclip gem and i have been trying out some examples
I'm very new to RoR, moving from PHP. I have what I hope is
I recently started a new RoR project, and copied some of my old code
We are new to ROR, We have issue in creating Login/Logout process in ROR
I'm quite new to RoR. Sorry if I'm using wrong terminology or the answer

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.