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

  • Home
  • SEARCH
  • 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 6165225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:07:44+00:00 2026-05-23T22:07:44+00:00

I have an array of select boxes which are added programmatically. Their names are

  • 0

I have an array of select boxes which are added programmatically. Their names are “array-ified” (see below).

<select name="blah[]">
    <option value="A">A</option>
    <option value="B">B</option>
</select>
<select name="blah[]">
    <option value="A">A</option>
    <option value="B">B</option>
</select>
<!-- and more... -->

When each is added, I want to add an onChange which will examine its selection. If the selection value is “A”, then all of the blah[] selects above it will be set to “A”. If the selection value is “B”, then all of the blah[] selects below will be set to “B”.

Any idea on how to do this, other than by setting the names manually when I add the fields programmatically (“blah1”, “blah2”, etc…)? Can jQuery get the index of each element somehow?

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-23T22:07:45+00:00Added an answer on May 23, 2026 at 10:07 pm

    .index() should do the trick

    $('select').live('change', function() {
        var index = $('select').index(this);
        $('select').each(function(i) {
            if ( i < index ) {
                // do something to ones above
            }
            else ( i > index ) {
                // do something to ones below
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have two select boxes, the second of which is dependent upon the selection
I have array like below array(1) { [data]=> array(6) { [0]=> array(2) { [name]=>
I have an array of countries that I will be using in a select
I have this php code $jsonArray = array(); $sql = SELECT ID,CLIENT FROM PLD_SERVERS;
I have such select list in html: <input type=checkbox name=drive_style value=1 checked />123<br />
I have a grid view with multiple select check boxes. I want to return
I have a Zend form with three select boxes. When the form is first
I have a standard select box which I'm populating using jquery by appending options,
I have two pages. One with the select boxes on and the send button.

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.