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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:32:43+00:00 2026-06-09T20:32:43+00:00

so I have an Array that is filled with a bunch of repeats like

  • 0

so I have an Array that is filled with a bunch of repeats like ['hey','hey','yeh'] and I have a html form that removes any entry from my Array if the submitted text matches it. However, my JS/jQuery doesn’t seem to be functioning the way I like. Only the first few entries seem to delete every time I press the button, as opposed to all the matches (which is what I want). Shouldn’t my “each” function be going through all the items in my array and deleting all of the entries that match whatever was submitted?

HTML:

<form id="remove_user" action="#" method="post">
        <label for="user_num">Remove user:</label>
        <input type="text" id="user_num" name="user_num" placeholder="number">
        <input type="submit" value="(-) remove">
    </form><!-- #remove_user -->

    <ul id="user_list"></ul><!-- #user_list -->

JS updated with a change, but still doesn’t work:

$('#remove_user').submit(function(){
    id = $('#user_num').val();
    $.each(myArr, function(i, value){
        if (value == id){
            myArr.splice(i, 1);
        };
    });
    $('#user_list').html('');
    for (var i=0; i < myArr.length; i += 1) {
        $('#user_list').append('<li>' +myArr[i]+ '</li>');
    };
    return false;
});
  • 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-09T20:32:44+00:00Added an answer on June 9, 2026 at 8:32 pm

    hey i think this should be like this.

    $.each(myArr, function(i, value){
        if (value == id){
            // delete myArr[myArr.indexOf(value)];
            myArr.splice(i, 1); //i is current index
    

    };

    EDIT

    $('#remove_user').submit(function() {
    id = $('#user_num').val();
    $.each(myArr, function(i, value) {
        if (value == id) {
            myArr.splice(i, 1, '');
        };
    });
    

    FIDDLE

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

Sidebar

Related Questions

I have a string array that is being filled dynamically.... I would like to
I have an array and filled its values like that: $('#list input:checked').each(function() { deleteRecordIdsStr.push($(this).attr('name'));
I have one array that is filled by mysql_query. Values that are in this
I have an array that looks something like this: Array ( [0] => apple
I have an array that looks like this: [ Object actions: Array[2] comments: Object
I have an array that is produced from people wanting to reserve a time
I have a bunch of name/email fields in my form like this: data[Friend][0][name] data[Friend][1][name]
We have an array filled with category names (many of them repeats) and we
I have an array filled with image links and I'd like to write a
I have an array filled with paths looking like this: library/main/single/list.php library/article/grid/thumbs.php library/footer/tiny.php These

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.