JSFiddle - React, Tailwind, and code Playground

Create multiple dropdowns from a selection from the first dropdown

by Akram kamal

HTML

<select name="rooms">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    <option>10</option>
</select>
<select name="adults">
    <option>1</option>
</select>

JavaScript

$("[name=rooms]").change(function () {
    $(this.options).slice($("[name=adults] option").length, this.selectedIndex + 1).clone().appendTo("[name=adults]")
    $("[name=adults] option").slice( this.selectedIndex + 1).remove()
    $("[name=adults]").prop("selectedIndex",this.selectedIndex)
})