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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:57:36+00:00 2026-06-13T01:57:36+00:00

I am stuck on a problem where I want to remove all the list

  • 0

I am stuck on a problem where I want to remove all the list that fall after selected list.
I have created JS Fiddle here but it doesn’t work. For example, if I select item from first drop-down then next two should removed, or if I select from second drop-down then third should be removed.

HTML

<div id='levels'>
<select id="level" class="parent" name="data[level][]">
    <option value="1">1</option>
<option value="2">2</option>
    </select>
    <select id="level" class="parent" name="data[level][]">
    <option value="3">3</option>
<option value="4">4</option>
    </select>
 <select id="level" class="parent" name="data[level][]">
    <option value="5">5</option>
<option value="6">6</option>
    </select>   
    </div>

Javascript

$("#levels").on('change', function() {
    $(this).nextAll().remove();

    });​

I want to achieve this without assigning different class names or div names to each list.

Cakephp Code

Master File

<script type="text/javascript">
$(document).ready(function() {


 $("select").on('change', function() {
    $(this).nextAll('select').remove();
        $("<div>").load('/dashboard/details/show_levels',function() {
    $("#levels").append($(this).html());

});
})


<div id=levels>

    <?php echo $form->input('level',array('options'=>$level,'type'=>'select','scroabble'=>true,'multiple'=>true, 'class'=>'parent')); ?>
</div>


});

show_levels

<?php
$abc=array('a','b','c','d');
echo $form->input('level',array('options'=>$abc,'type'=>'select','scroabble'=>true,'multiple'=>true, 'class'=>'parent')); ?>

Update:

Follwing solution worked for me

Replaced

 $(this).nextAll('select').remove();

with

$(this).parents().nextUntil().remove();

Not sure how it worked, and whats the difference between two.

  • 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-13T01:57:38+00:00Added an answer on June 13, 2026 at 1:57 am

    Follwing solution worked for me

    Replaced

     $(this).nextAll('select').remove();
    

    with

    $(this).parents().nextUntil().remove();
    

    Not sure how it worked, and whats the difference between two.

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

Sidebar

Related Questions

I'm stuck with a problem and hope stackoverfolw community can help me. I want
How can i stack images onto eachother? My problem is that i want the
I'm stuck on a problem I really don't know how to solve: I have
I'm trying to create a Regex javascript split, but I'm totally stuck. Here's my
I have been searching for a solution to my problem but haven't found anything
I have an old website originally created in MS Frontpage that I'm trying to
I have four numbers that can possible be the same, but or most likely
I am stuck on a weird problem. I have a CashGameGeneralViewModel class which looks
I am using jsp for a web based project. i want to remove all
I'm stuck with a php array problem. I've to a webpage that takes values

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.