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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:29:33+00:00 2026-06-03T23:29:33+00:00

Suppose we have 5 checkboxes and each has unique value mapped with respective list

  • 0

Suppose we have 5 checkboxes and each has unique value mapped with respective list of elements, just in my case I have associative PHP array –

[100] => Array ( [0] => Array ( [name] => NameABC [sid] => 109 ) 
                 [1] => Array ( [name] => NameDEF [sid] => 110 ) 
               ) 

[101] => Array ( [0] => Array ( [name] => NamePQR [sid] => 337 ) 
                 [1] => Array ( [name] => NameXYZ [sid] => 339 ) 
               ) 

so the values can be mapped with each list, now by the property of checkbox you can select more than one checkbox (unlike radio button), so when such case comes the drop down list that is being populated on the basis of each checkbox selection, now comes in a merged format like on selecting OPTION 1 and OPTION 2 both the list contains all the elements mapped to both, further on de-selecting it comes back to unmerged state.

  • 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-03T23:29:34+00:00Added an answer on June 3, 2026 at 11:29 pm

    Finally after iterations on my own question, I found almost correct answer for the same. Below is the HTML snippet used by me in this —

    <tr>
    <td align="center"  bgcolor="#BFD5EA" width="30%"><font size="1" face="Verdana"><b>Sales Channel :&nbsp;</b></font></td>
    <td bgcolor="#E4E4E4" colspan="5"><font size="1" face="Verdana" width="70%">
    ~foreach from=$sales_channel item=r`
        <input type="checkbox" name="salestype[]" value="~$r.ROLE`"  id="~ $r.NAME`" >~$r.NAME`&nbsp;
    ~/foreach`
    </td>
    </tr>   
    <tr style="display: none" id="nafrat"><td align="center"  bgcolor="#BFD5EA" width="30%"><font size="1" face="Verdana"><b>List of Executives:</font></b></td>
    <td bgcolor="#E4E4E4" colspan="5" width="70%">
        <select name="selOnlSrc[]"  id="myops" multiple size="10" ><!--@@@@Done-->
        ~foreach from=$assigner key=k item=r`
            ~foreach  from=$r item=m`
                <option id="allexec" value="all" selected>All</option>
                <option class="~$k`" class="searchSelect"  style="display: none"   value="~$m.execid`">~$m.display_name`</option>
            ~/foreach` 
        ~/foreach` 
        </select> 
    </td>                          
    

    And now most important is the jquery part —

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript">  </script>
    <script>
    $(document).ready(function() {
    
    $("input[name=salestype[]]:checkbox").click(function() {
      var selected = new Array();
      $('#nafrat').show();
      $("input:checkbox[name=salestype[]]:checked").each(function() {
        selected.push($(this).val());
        });
      $('#myops').children('option').hide();
      var btnchk= new Array();
      btnchk = $('input:checkbox[name="salestype[]"]:checked');
    
      if (btnchk.length) {
      $('#allexec').show();
      }
      else {
      $('#allexec').hide();
      $('#nafrat').hide();
      }
      $.each( selected, function(i, l){
          $('.'+l).show();
          });
      selected = new Array();
      btnchk  = new Array();
    
    });
    </script>
    

    For this I am able to get values in the drop-down merged on selecting two or more check-boxes and further on un-checking any one, removes the respective contents from the list below.

    NOTE: the HTML displayed above contains smarty tags and also have some PHP variables like “$assigner” etc.

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

Sidebar

Related Questions

I have a list of checkboxes, each one with a label: <input type=checkbox id=patient-birth_city
I have a table with multiple rows. Each row has a check button. How
I have the following checkbox created by a loop: <input type='checkbox' value=0 name='<?php echo
I have a form on the page. It has too many things like checkboxes
I have a list of checkboxes with the same name attribute, and I need
Suppose I have two comboboxes. One for the lower-value and one for the upper
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
I'm trying to get an object of checkbox names and values. Suppose I have
suppose I have {data: {243232: {id: testid,name: test } }} so how to get
Suppose I have established a connection on a socket and got a Posix error

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.