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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:09:04+00:00 2026-06-08T17:09:04+00:00

I have the below working based on the accepted answer in this question .

  • 0

I have the below working based on the accepted answer in this question.

see this link for how this works

<form action="" name="testform" method="post" id="testform">
<div id='div_block1'>
<input type="text" value="" name="a[]" class='input_text'>
<input type="text" value="" name="b[]" class='input_text'>
<input type="text" value="" name="c[]" class='input_text'>
<select id='block1'>
    <option value="" data-value=""></option>
    <option value="1" data-value="11,12,13">1</option>
    <option value="2" data-value="21,22,23">2</option>
    <option value="3" data-value="31,32,33">3</option>
    <option value="4" data-value="41,42,43">4</option>
    <option value="5" data-value="51,52,53">5</option>
</select>     
</div>
<div id='div_block2'>        
<input type="text" value="" name="a[]" class='input_text'>
<input type="text" value="" name="b[]" class='input_text'>
<input type="text" value="" name="c[]" class='input_text'>
<select id='block2'>
    <option value="" data-value=""></option>
    <option value="1" data-value="11,12,13">1</option>
    <option value="2" data-value="21,22,23">2</option>
    <option value="3" data-value="31,32,33">3</option>
    <option value="4" data-value="41,42,43">4</option>
    <option value="5" data-value="51,52,53">5</option>
</select>     
</div>
</form>
<script>
$(function() {
$('select').on('change', function() {
    var div_id = 'div_'+$(this).attr('id');
    var select_val = $(this).find('option:selected').data('value');
    console.log();
        if( select_val != '' ) {
            var a = select_val.split(',');
            $('div#'+div_id+' input[name="a[]"]').val(a[0]);
            $('div#'+div_id+' input[name="b[]"]').val(a[1]);
            $('div#'+div_id+' input[name="c[]"]').val(a[2]);
        } else {
            $('div#'+div_id+' input.input_text').val('');
            }
    });
});    
</script>

I want to change it up slightly so that if I select 1 for example I get two values for a[], b[], c[]

I have done the below

<form action="" name="testform" method="post" id="testform">
<div id='div_block1'>
<input type="text" value="" name="a[]" class='input_text'>
<input type="text" value="" name="b[]" class='input_text'>
<input type="text" value="" name="c[]" class='input_text'>
<input type="text" value="" name="a[]" class='input_text'>
<input type="text" value="" name="b[]" class='input_text'>
<input type="text" value="" name="c[]" class='input_text'>        
<select id='block1'>
    <option value="" data-value=""></option>
    <option value="1" data-value="11,12,13,6,12,8">1</option>
    <option value="2" data-value="21,22,23,8,10,33">2</option>
    <option value="3" data-value="31,32,33,2,8,6">3</option>
    <option value="4" data-value="41,42,43,22,54,63">4</option>
    <option value="5" data-value="51,52,53,12,34,55">5</option>
</select>     
</div>
<div id='div_block2'>        
<input type="text" value="" name="a[]" class='input_text'>
<input type="text" value="" name="b[]" class='input_text'>
<input type="text" value="" name="c[]" class='input_text'>
<input type="text" value="" name="a[]" class='input_text'>
<input type="text" value="" name="b[]" class='input_text'>
<input type="text" value="" name="c[]" class='input_text'>
<select id='block2'>
    <option value="" data-value=""></option>
    <option value="1" data-value="11,12,13,95,44,32">1</option>
    <option value="2" data-value="21,22,23,12,35,51">2</option>
    <option value="3" data-value="31,32,33,21,12,24">3</option>
    <option value="4" data-value="41,42,43,35,52,15">4</option>
    <option value="5" data-value="51,52,53,23,42,15">5</option>
</select>     
</div>
</form>    

see fiddle. From my understanding of how the first one worked I thought this would work however it is only taking the last value for a[], b[], c[] eg 6,12,8,6,12,8 instead of 11,12,13,6,12,8 if you select 1.

What else do I need to add to get this working as desired?

  • 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-08T17:09:06+00:00Added an answer on June 8, 2026 at 5:09 pm

    I simplified the JS

    Add a class to suit any flag for the inputs

    <div>
        <form action="" name="testform" method="post" id="testform">
        <div id='div_block1'>
            <input type="text" value="" name="a[]" class='input_text flag'>
            <input type="text" value="" name="b[]" class='input_text flag'>
            <input type="text" value="" name="c[]" class='input_text flag'>
            <input type="text" value="" name="a[]" class='input_text flag'>
            <input type="text" value="" name="b[]" class='input_text flag'>
            <input type="text" value="" name="c[]" class='input_text flag'>
            <select id='block1'>
            <option value="" data-value=""></option>
            <option value="1" data-value="11,12,13,6,12,8">1</option>
            <option value="2" data-value="21,22,23,8,10,33">2</option>
            <option value="3" data-value="31,32,33,2,8,6">3</option>
            <option value="4" data-value="41,42,43,22,54,63">4</option>
            <option value="5" data-value="51,52,53,12,34,55">5</option>
            </select>     
        </div>
        <div id='div_block2'>        
            <input type="text" value="" name="a[]" class='input_text flag'>
            <input type="text" value="" name="b[]" class='input_text flag'>
            <input type="text" value="" name="c[]" class='input_text flag'>
            <input type="text" value="" name="a[]" class='input_text flag'>
            <input type="text" value="" name="b[]" class='input_text flag'>
            <input type="text" value="" name="c[]" class='input_text flag'>
            <select id='block2'>
            <option value="" data-value=""></option>
            <option value="1" data-value="11,12,13,95,44,32">1</option>
            <option value="2" data-value="21,22,23,12,35,51">2</option>
            <option value="3" data-value="31,32,33,21,12,24">3</option>
            <option value="4" data-value="41,42,43,35,52,15">4</option>
            <option value="5" data-value="51,52,53,23,42,15">5</option>
            </select>     
        </div>
        </form>
    <div>
    

    Now use the following JS

    $(function() {
    $('select').on('change', function() {
        var div_id = 'div_'+$(this).attr('id');
        var select_val = $(this).find('option:selected').data('value');
        console.log();
        if( select_val != '' ) {
            var a = select_val.split(',');
            var count = 0;
            $('div#'+div_id+' .flag').each(function() {
                $(this).val(a[count]);
                ++count;
            });
        } else {
            $('div#'+div_id+' input.input_text').val('');
        }
    });
    

    });​

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

Sidebar

Related Questions

Problem solved, see below Question I'm working in Flex Builder 3 and I have
Edit: Below is my working code based on the feedback/answers I recieved. This question
I am working with DNA sequences of length 25 (see examples below). I have
I have below a working query that needs to be simplified. The reason is
Code below is working well as long as I have class ClassSameAssembly in same
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I am working on icon based main menu for my Android application (see attached
I am working with drawing polygons based on a given line. I have the
I am working the following question for my Oracle class. I have the solution

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.