Thursday, February 2, 2023
Learning Code
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#
No Result
View All Result
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#
No Result
View All Result
Learning Code
No Result
View All Result
Home JavaScript

How do I filter the text, “positivity” while preserving parents? – JavaScript – SitePoint Forums

learningcode_x1mckf by learningcode_x1mckf
October 6, 2022
in JavaScript
0
Time limit for notify – JavaScript – SitePoint Forums
74
SHARES
1.2k
VIEWS
Share on FacebookShare on Twitter


You might also like

Pay What You Want for this Learn to Code JavaScript Certification Bundle

How to have a Smooth/Fast scroll in mobile popup window? – JavaScript – SitePoint Forums

JavaScript Token (JS) Do the Risks Outweigh the Rewards Wednesday?

How do I filter the textual content, “positivity” whereas preserving mother and father. Notice the mother and father are in ascending order. Instance you probably have ‘the category child-1’ is a baby child-2 is one other youngster and so forth. When you might have a category child-0 adopted by one other child-0 the primary class child-0 has no youngsters. Pure javascript please. Thanks upfront.

<!DOCTYPE html>
<html lang="pt-BR">
    <head>
        <meta charset="UTF-8">   
    </head>
    <physique>
        <kind>
            <enter kind="textual content" id="searchFilter" title="searchFilter" placeholder="Search" 
                   onkeyup="filterItems(this);">
            <choose id="help-my-brother" title="ddVehicles" dimension="4">
                <choice worth="-1">None</choice>
                <choice class="child-0" worth="1">United States</choice>
                <choice class="child-0" worth="2">Australia</choice>
                <choice class="child-0" worth="3">Brazil</choice>
                <choice class="child-1" worth="4">&nbsp;&nbsp;&nbsp;Iceland</choice>
                <choice class="child-2" worth="5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UK</choice>
                <choice class="child-0" worth="6">Germany</choice>
                <choice class="child-1" worth="7">&nbsp;&nbsp;&nbsp;Italy</choice>
                <choice class="child-2" worth="8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;France</choice>
                <choice class="child-3" worth="9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;China</choice>
                <choice class="child-4" worth="10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;positivity</choice>
                <choice class="child-0" worth="11">Japan</choice>
                <choice class="child-0" worth="12">Argentina</choice>
                <choice class="child-0" worth="13">Colombia</choice>
                <choice class="child-0" worth="14">Mexico</choice> 
                <choice class="child-0" worth="15">Chile</choice>
                <choice class="child-0" worth="16">Venezuela</choice>
                <choice class="child-0" worth="17">Peace and love</choice>
                <choice class="child-0" worth="18">Florida</choice>
                <choice class="child-1" worth="19">&nbsp;&nbsp;&nbsp;Hug</choice>
                <choice class="child-2" worth="20">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Motion</choice>
                <choice class="child-3" worth="21">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adaptable</choice>
                <choice class="child-4" worth="22">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;positivity</choice>
                <choice class="child-0" worth="23">Love</choice>
                <choice class="child-1" worth="24">&nbsp;&nbsp;&nbsp;charisma</choice>
                <choice class="child-2" worth="25">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allure</choice>
                <choice class="child-3" worth="26">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;positivity</choice>
                <choice class="child-4" worth="27">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Good friend</choice>
                <choice class="child-0" worth="28">Peru</choice>
                <choice class="child-1" worth="29">&nbsp;&nbsp;&nbsp;readability</choice>
                <choice class="child-0" worth="30">collaboration</choice>
                <choice class="child-0" worth="31">companionship</choice>
                <choice class="child-0" worth="32">Communication</choice>
                <choice class="child-0" worth="33">dependable</choice>
            </choose>
        </kind>
        <script>
            var optionsCache = [];
            operate filterItems(el) 
                var worth = el.worth.toLowerCase();
                var kind = el.kind;
                var decide, sel = kind.ddVehicles;
                if (worth == '') 
                    restoreOptions();
                 else 
                    // Loop backwards via choices as eradicating them modifies the subsequent
                    // to be visited if go forwards
                    for (var i = sel.choices.size - 1; i >= 0; i--) 
                        decide = sel.choices[i];
                        if (decide.textual content.toLowerCase().indexOf(worth) == -1) 
                            sel.removeChild(decide)
                        
                    
                
            

// Restore choose to authentic state
            operate restoreOptions() 
                var sel = doc.getElementById('help-my-brother');
                sel.choices.size = 0;
                for (var i = 0, iLen = optionsCache.size; i < iLen; i++) 
                    sel.appendChild(optionsCache[i]);
                
            

            window.onload = operate () 
                // Load cache
                var sel = doc.getElementById('help-my-brother');
                for (var i = 0, iLen = sel.choices.size; i < iLen; i++) 
                    optionsCache.push(sel.choices[i]);
                
            
        </script>
    </physique>
</html>

I’m confused.

Are you able to present us what your required end-state can be, given the above as a starting-state?

1 Like

I believed higher of it and it could be good if the kid confirmed up. the end result within the seek for positivity must be this.
``

<kind>
            <enter kind="textual content" id="searchFilter" title="searchFilter" placeholder="Search" 
                   onkeyup="filterItems(this);">
            <choose id="help-my-brother" title="ddVehicles" dimension="4">
                <choice class="child-0" worth="6">Germany</choice>
                <choice class="child-1" worth="7">&nbsp;&nbsp;&nbsp;Italy</choice>
                <choice class="child-2" worth="8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;France</choice>
                <choice class="child-3" worth="9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;China</choice>
                <choice class="child-4" worth="10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;positivity</choice>
                <choice class="child-0" worth="18">Florida</choice>
                <choice class="child-1" worth="19">&nbsp;&nbsp;&nbsp;Hug</choice>
                <choice class="child-2" worth="20">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Motion</choice>
                <choice class="child-3" worth="21">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adaptable</choice>
                <choice class="child-4" worth="22">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;positivity</choice>
                <choice class="child-0" worth="23">Love</choice>
                <choice class="child-1" worth="24">&nbsp;&nbsp;&nbsp;charisma</choice>
                <choice class="child-2" worth="25">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allure</choice>
                <choice class="child-3" worth="26">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;positivity</choice>
                <choice class="child-4" worth="27">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Good friend</choice>
            </choose>
        </kind>

`

Ah okay, I get it now.

Properly, right here’s the logic for the way i'd do it. I've made no effort to optimize it.

Create an array, with dimension equal to the variety of choices, and fill it with false. We’ll name it masks.
Set masks[0] to true.
For 1 to the variety of choices i
If mytext accommodates “prosperity”,
For 0 to the variety of that aspect’s child-class, known as j
Set masks[i-j] equal to true.
Endfor j
EndIf
Endfor i
Foreach masks as worth utilizing index;
if worth is fake,
take away the index’th choice aspect from the DOM.
Endif
Endforeach.



Source link

Share30Tweet19
learningcode_x1mckf

learningcode_x1mckf

Recommended For You

Pay What You Want for this Learn to Code JavaScript Certification Bundle

by learningcode_x1mckf
February 2, 2023
0
Pay What You Want for this Learn to Code JavaScript Certification Bundle

Deal Neowin Offers · Oct 4, 2021 - Up to date Jan 31, 2023 13:00 EST Jumpstart your profitable profession in coding and programmingRight now's highlighted deal comes...

Read more

How to have a Smooth/Fast scroll in mobile popup window? – JavaScript – SitePoint Forums

by learningcode_x1mckf
February 2, 2023
0
Different server for Google API – JavaScript – SitePoint Forums

Hello Associates,Sorry I need to appropriate the positioning tackle to this: http://dev.harfrooz.com/I searched quite a bit and I came upon that my downside is expounded to iscroll.js File....

Read more

JavaScript Token (JS) Do the Risks Outweigh the Rewards Wednesday?

by learningcode_x1mckf
February 1, 2023
0
JavaScript Token (JS) Do the Risks Outweigh the Rewards Wednesday?

News Home Wednesday, February 01, 2023 07:38 AM | InvestorsObserver Analysts JavaScript Token receives a excessive risk score from InvestorsObserver evaluation. The proprietary scoring system analyzes how a...

Read more

Discord Rich Presence – JavaScript – SitePoint Forums

by learningcode_x1mckf
February 1, 2023
0
Different server for Google API – JavaScript – SitePoint Forums

Hiya! Extraordinarily new to java-script and I’m making an attempt to make use of discordjs-rpc to make one thing that can change my standing based mostly on no...

Read more

WebAssembly vs. JavaScript: Security, Speed, Flexibility

by learningcode_x1mckf
February 1, 2023
0
WebAssembly vs. JavaScript: Security, Speed, Flexibility

In direction of the start of what's popularly referred to as the World Extensive Net, there was JavaScript. JavaScript has been round since 1995 when Brendan Eich created...

Read more
Next Post
Front End Java Angular Developer

Front End Java Angular Developer

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related News

West Java deploys village patriots for building rural human resources

West Java deploys village patriots for building rural human resources

October 10, 2022
8 Ways to Fix the Microsoft Visual C++ Install Error 0x80240017 on Windows

8 Ways to Fix the Microsoft Visual C++ Install Error 0x80240017 on Windows

September 14, 2022
Why are shallow earthquakes more destructive? The disaster in Java is a devastating example

Why are shallow earthquakes more destructive? The disaster in Java is a devastating example

November 24, 2022

Browse by Category

  • C#
  • C++
  • Java
  • JavaScript
  • Python
  • Swift

RECENT POSTS

  • Java :Full Stack Developer – Western Cape saon_careerjunctionza_state
  • Pay What You Want for this Learn to Code JavaScript Certification Bundle
  • UPB Java Jam brings coffeehouse vibes to Taylor Down Under | Culture

CATEGORIES

  • C#
  • C++
  • Java
  • JavaScript
  • Python
  • Swift

© 2022 Copyright Learning Code

No Result
View All Result
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#

© 2022 Copyright Learning Code

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?