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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:29:21+00:00 2026-06-13T11:29:21+00:00

This is a form_for in my Rails view: <div class=field> <%= f.label :num1 %><br

  • 0

This is a form_for in my Rails view:

<div class="field">
  <%= f.label :num1 %><br />
  <%= f.text_field :num1 %>
  <%= f.label :num2 %><br />
  <%= f.text_field :num2 %>
  <%= f.label :sum %><br />
  <%= f.text_field :sum %>
</div>

I would like to make it so that, when the user inputs numbers into the first two fields, the third field automatically shows the sum of the two numbers, but the user can manually change the third field. I’m not sure how I could do this, maybe with some Javascript?

  • 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-13T11:29:22+00:00Added an answer on June 13, 2026 at 11:29 am

    It’s pretty simple with jQuery:

    $('#num1').change(function() {
        var one = this.val();
        var two = $('#num2').val();
        $('#sum').val(one + two);
    });
    $('#num2').change(function() {
        var one = $('#num1').val();
        var two = this.val();
        $('#sum').val(one + two);
    });
    

    Done.

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

Sidebar

Related Questions

I have a nested form in a rails view that is called like this
This is my view: = form_for(@user) do |f| = f.autocomplete_field @user.city.name, autocomplete_city_name_users_path On the
I'm using Rails 2.3.4/Ruby 1.9.1 for my application. In the view I have this
I generated a search_contoller and view for my rails app. My Controller: class SearchController
I have a form partial that looks like this: <%= form_for(@pool) do |f| %>
I have this in one of my haml views: -form_for :news_item_comment, :url=>{:id => comment.id,
I have a simple form that looks like this: <%= simple_form_for @study,:url => studies_path,
I'm new to Rails development, so please bear with me. I'm creating a view
I was trying out Rails again, this time the 3 version, but I got
Help me understand this; I'm learning Sinatra (and Rails for that matter, er, and

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.