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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:54:08+00:00 2026-05-22T12:54:08+00:00

I have a rails form where user has to select a value from a

  • 0

I have a rails form where user has to select a value from a drop down menu and based on that value, the rest fo the form elements are displayed.

<div id="A">
a
b
c
</div>

<div id="B">
x
y
z
c
</div>

<div id="B">
w
a
q
c
</div>

When user selects value A from the select menu, the div with id A is displayed and the rest of the divs are hidden.

The problem is some fields are repeated in the different divs and when user enters a value for field ‘a’ in div A, this value gets overwritten by the blank value in div B, although div B is hidden from view.

I would like to know whether it’s possible to have the same fields in different divs and be able to store the value of the field found in the displayed div only, even if that field is found in other divs.

Many many thanks for any suggestion provided.

  • 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-22T12:54:09+00:00Added an answer on May 22, 2026 at 12:54 pm

    When you hide your div, turn on the disabled attribute for all children and when you show a div remove it. Something like this:

    var showDiv = function ( id ) {
        var all = [document.getElementById( 'A' ), 
                   document.getElementById( 'B' ), 
                   document.getElementById( 'C' )],
            cur = document.getElementById( id ),
            inps;
    
        for (var i = 0, il = all.length; i < il; i++) {
    
            inps = all[i].getElementsByTagName('input');
    
            for (var j = 0, jl = inps.length; j < jl; j++) {
                inps[j].setAttribute('disabled', 'disabled');
            }
    
            all[i].style.display = 'none';
    
        }
    
        inps = cur.getElementsByTagName('input');
    
        for (j = 0, jl = inps.length; j < jl; j++) {
            inps[j].removeAttribute('disabled');
        }
    
        cur.style.display = 'block';
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select list drop down in my Rails application, in the form
I have a rails model that validates uniqueness of 2 form values. If these
I have a rails application where each user has a separate database. (taking Joel
Background, Part 1 I have a form that collects both frequency and duration from
I have created the following select using the option_groups_from_collection_for_select form helper in Rails as
I have a partial in my rails app that loads the vote form (It's
I'm creating a form in a Rails 3 app that has a dropdown field.
I have a rails form with a datetime_select field. When I try to submit
In my Rails app, I have a form which redirects through a foreign service,
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base

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.