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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:41:13+00:00 2026-05-16T08:41:13+00:00

How can I filter more than one list item with one checkbox? Thanks. <html>

  • 0

How can I filter more than one list item with one checkbox? Thanks.

<html>

<head>
<script type="text/javascript">
<!--
window.onload=function()
{
    document.getElementById('onclick').onclick=function()
    {
    var check=document.getElementsByTagName('input'),
    lis=document.getElementsByTagName('li'),i=0;

for(var i;i<check.length,i<lis.length;i++)
    {
    lis[i].style.display='none';
    if(check[i].type=='checkbox')
        {
        if(check[i].checked==true)
        lis[i].style.display='';
        }}}}
//-->
</script>
</head>

<body>

<form style="width:600px;">

<div style="width:600px">

<div style="float:right; width:200px;">
<li>Red</li>
<li>Black</li>
<li>Green</li>
<li>Yellow</li>
<li>Blue</li>
<li>White</li>

<br>
</div>

<div>
<input type="checkbox"/><label>Red</label>
<br>
<input type="checkbox"/><label>Black</label>
<br>
<input type="checkbox"/><label>Green</label>
<br>
<input type="checkbox"/><label>Yellow</label>
<br>
<input type="checkbox"/><label>Blue</label>
</div>
<input type="checkbox"/><label>White</label>
<br>
<br>


<input type="button" name="onclick" id="onclick" value="Submit">
<br>
</div>
</form>
</body>

  • 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-16T08:41:13+00:00Added an answer on May 16, 2026 at 8:41 am

    What I can think of is to use the “id” attribute for the “li” tags and control its visibility by an event attribute from its relevant “input” tag (or from any input tag).

    <script>
      function processme(id_chk, id_li){
            var li = document.getElementById(id_li)
            //1. Add more list elements here if required OR
            //2. do a getElementByTagName and negate li
            if (document.getElementById(id_chk).checked == true) li.style.visibility = ''
            else li.style.visibility = 'hidden'  
        }
    </script>
    
    <form style="width:600px;">
    
        <div style="width:600px">
    
            <div style="float:right; width:200px;">
                <li id="red_li">Red</li>
                <li id="black_li">Black</li>
                <li>Green</li>
                <li>Yellow</li>
                <li>Blue</li>
                <li>White</li>
    
                <br>
            </div>
    
            <div>
                <input type="checkbox" id="red_chk" onclick="javascript:processme('red_chk', 'red_li')" /><label>Red</label>
                <br>
                <input type="checkbox" id="black_chk" onclick="javascript:processme('black_chk', 'black_li')" /><label>Black</label>
                <br>
                <input type="checkbox"/><label>Green</label>
                <br>
                <input type="checkbox"/><label>Yellow</label>
                <br>
                <input type="checkbox"/><label>Blue</label>
            </div>
            <input type="checkbox"/><label>White</label>
            <br>
            <br>
    
    
            <input type="button" name="onclick" id="onclick" value="Submit">
            <br>
        </div>
    </form>​
    

    ref: http://jsfiddle.net/TdCDW/

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

Sidebar

Related Questions

Within one filter, how can I match more than one action of the same
I want to do a combobox, but my user can select more than one
How we can filter the object in List<> in C#?
Can log4net filter and replace matched log message? <filter type=log4net.Filter.StringMatchFilter> <param name=AcceptOnMatch value=false />
Is there a way in Python, to have more than one constructor or more
When I create a report I can filter the results based on the logged
I have an application that can filter a datagridview based on date using a
I'm trying to make a cgridview that can filter data from relations table. This
any quick tip to implement findAllByGreaterThan so I can filter those records which date
I'm building an events page similar to last.fm/events The user can filter events by

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.