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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:39:32+00:00 2026-05-25T16:39:32+00:00

I have the next html code: <fieldset id=q1> <legend>Quest 1</legend> <div class=a1> <label for=q2a1>Some

  • 0

I have the next html code:

<fieldset id="q1">
  <legend>Quest 1</legend>
  <div class="a1">
    <label for="q2a1">Some text 1</label>
    <select id="q2a1" name="q2a1">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
    </select>
  </div>
  <div class="a2">
    <select id="q2a2" name="q2a2">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
    </select>
    <label for="q2a2">Some text 2</label>
  </div>
</fieldset>

The basic idea: the sum of the two selectors must be equal to 2.

Example: If I choose the in the first selector number 2, the second selector must be avaible
the 0 only. If I choose in the first selector number 1, the second selector must
must have only 1. And vice versa.
As you can see the tag label can be located before and after select.
I started writing code, but it stuck on choosing a necessary child.
Also likely not be able to use elements by the id, because the form a very large.

js:

$('select').change(function(event) {
  var c;
  c = 3 - $(this).val();
  options = '';
  for (var i = 0; i <= c; i++) {
    options += '<option value="' + i + '">' + i + '</option>';
  }
        alert($(this).parent().parent().html());
});

Any ideas? 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-25T16:39:32+00:00Added an answer on May 25, 2026 at 4:39 pm

    You don’t have to look for the element, you can simply use .val(value), and jQuery does the hard work for you:

    $('select').bind('change keyup click', function(){
       var $this = $(this);
       var $other = $this.closest('fieldset').find('select').not(this);
       var selectedValue = parseInt($this.val(), 10);
       $other.val(2 - selectedValue);
    });
    

    I’ve added the keyup and click events so it plays nicely with the mouse and keyboard.

    Working example: http://jsfiddle.net/7TX86/1

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

Sidebar

Related Questions

I have following html. <fieldset id=fieldset-step_3> <input type=text value=2 id=rule_form-lead_time name=rule_form[lead_time]> <select class=w50 id=rule_form-operator
I have the following html code: <div id=result1 class=result> ... some html ... ...
I have the next code with some thumbnails: <div class=gallery-wrap> <div class=gallery galleryid-45 id=gallery-1>
HTML Code Snippet: <fieldset id=o-bs-sum-buginfo> <label for=o-bs-sum-bug-ErrorPrefix>Error Prefix</label> <input type=text id=o-bs-sum-bug-ErrorPrefix name=ErrorPrefix value= />
I have this html code <div id=mydiv> <div> <span>Text inside span</span> Text next to
I have some html code, so: <div class=ui-tabs-panel> <div class=dataTables_wrapper> <div> <button>Add Whatever</button> </div>
I have a HTML document which llokes like this: <div class=this_can_be_selected>Some text here</div> <div>No
I have the following html code: <div class=Radios> <span class=radio> <input type=radio value=1> yes
I have the following HTML code: <div class=container> <span class=red></span> <span class=hot></span> </div> On
I have next xsl code: <xsl:template match=/> <html> <!--some code here--> <body bgcolor=#FFFFFF> <xsl:apply-templates

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.