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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:02:38+00:00 2026-05-30T12:02:38+00:00

I’ve about pulled my hair out with this one.. I understand this could very

  • 0

I’ve about pulled my hair out with this one.. I understand this could very well be the wrong approach.. but my hands are somewhat tied.. Please do offer any suggestions though.

Hopefully this is enough to explain the issue..

Desire – Select on the “Controlling Row” manipulates the Select on the “Controlled Row”

Issues – If I do a while loop only the last column works (controls top row)

I realize I could hand code each column separately and not loop but want to componentize this and keep it small..

Thank you in advance!!

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Language" content="en-us" />
        <title>Selects Duplicated</title>
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script>
        $(document).ready(function(){ //runs when document.ready
            var $superduper;
                i=0;
                $Tbl_1 = "Tbl";

                while (i<=2)
                {
                    FltTbl = "#flt" + i + "_" + $Tbl_1;
                    FltTbl2 = "flt" + i + "_" + $Tbl_1 + "_" +"2";
                    ColContainer = "colcontainer" + i;

                    $((FltTbl)).clone().attr('id', (FltTbl2)).attr('class', (FltTbl2)).appendTo("#" + (ColContainer)).find('select > option:selected').each(function() {});
                    $(function() { 
                    $("#" + (FltTbl2)).change(function() { 
                    $((FltTbl)).val($(this).val()).trigger('change'); //this triggers when clone select changes //
                    });
                    });
                    i++;
                }
        });

        </script>

    </head>

    <body>
    <table id="Tbl0_2">
        <tr>
            <td width="70">
                <div>
                    <select id="flt0_Tbl" class="flt0_Tbl">
                        <option value="">--</option>
                        <option value="1-1">1-1</option>
                        <option value="1-2">1-2</option>
                        <option value="1-3">1-3</option>
                        <option value="1-4">1-4</option>
                    </select>
                </div>
            </td>
            <td width="70">
                <div>
                    <select id="flt1_Tbl" class="flt1_Tbl">
                        <option value="">--</option>
                        <option value="2-1">2-1</option>
                        <option value="2-2">2-2</option>
                        <option value="2-3">2-3</option>
                        <option value="2-4">2-4</option>
                    </select>
                </div>
            </td>
            <td width="70">
                <div>
                    <select id="flt2_Tbl" class="flt2_Tbl">
                        <option value="">--</option>
                        <option value="3-1">3-1</option>
                        <option value="3-2">3-2</option>
                        <option value="3-3">3-3</option>
                        <option value="3-4">3-4</option>
                    </select>
                </div>
            </td>
            <td>
            <div>Controlled Row</div>
            </td>
        </tr>
        <tr>
            <td width="70"><div class="colcontainer0" id="colcontainer0"></div></td>
            <td width="70"><div class="colcontainer1" id="colcontainer1"></div></td>
            <td width="70"><div class="colcontainer2" id="colcontainer2"></div></td>
            <td><div>Controlling Row</div></td>
        </tr>
        <tr>
            <td width="70"><div>Nope</div></td>
            <td width="70"><div>Nope</div></td>
            <td width="70"><div>Works</div></td>
        </tr>
    </table>
    </body>
    </html>

Link: http://jsfiddle.net/EpicVision/x9ASj/

  • 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-30T12:02:40+00:00Added an answer on May 30, 2026 at 12:02 pm

    The problem is that the triggering change uses the selectors from the closure that the loop is in, so the selectors are always going to be the third select box by the end of the loop, and therefore will be the third selector when the user clicks something.

    I’ve updated your fiddle http://jsfiddle.net/steveukx/x9ASj/1/ to show how to create a closure to fix the value of the selectors.

    (It’s worth noting that creating closures in a loop is generally considered bad practice).

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

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.