最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Sumo select remove all indexes and reset - Stack Overflow

matteradmin3PV0评论

I have integrated Sumoselect. select it for cascading state and city dropdown.

Initially City drop is blank. On section of States, it adds Options under City dropdown.

Question is how to remove all options of City dropdown, if someone de-selects all the selected states? There is only provision to remove options using index. So how to remove all the options at one time?

I have integrated Sumoselect. select it for cascading state and city dropdown.

Initially City drop is blank. On section of States, it adds Options under City dropdown.

Question is how to remove all options of City dropdown, if someone de-selects all the selected states? There is only provision to remove options using index. So how to remove all the options at one time?

Share Improve this question edited Jul 31, 2018 at 7:22 Nimeshka Srimal 8,9705 gold badges45 silver badges60 bronze badges asked May 19, 2016 at 13:38 AniketAniket 1291 silver badge10 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

You can delete all the HTML of the select element linked to SumoSelect and then reload the SumoSelect of that element. For example:

$('#MySelect').html('');
$('#MySelect')[0].sumo.reload();

Get all indexes in num variable.

var num = $('option').length;

for(var i=num; i>=1; i--)
{
   $('.SlectBox')[0].sumo.remove(i-1);
}
Post a comment

comment list (0)

  1. No comments so far