How does js achieve four-level form linkage?

topic description

there are four select,: building number, unit, floor and room number. The requirements are as follows:
A building, regardless of unit is empty, a total of 30 floors, room number to 1-20
B building, divided into 1, 2 units, 33 floors, room number to 1-6

sources of topics and their own ideas

comes from the actual development requirements, my own idea is to use jQuery to control the addition and deletion of dom nodes.

related codes

/ / here is the key html code I implemented

<div class="house">
    <div class="dong">
        <select id="dong">
            <option selected="selected" disabled="disabled" style="display: none"></option>
            <option>A</option>
            <option>B</option>
        </select>
        <span></span>
    </div>
    <div class="danyuan">
        <select id="danyuan">
            <option selected="selected" disabled="disabled" style="display: none"></option>
            <option>1</option>
            <option>2</option>
        </select>
        <span></span>
    </div>
    <div class="louceng">
        <select id="louceng">
            <!-- <option selected="selected" disabled="disabled" style="display: none"></option> -->
            <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>
            <option>11</option>
            <option>12</option>
            <option>13</option>
            <option>14</option>
            <option>15</option>
            <option>16</option>
            <option>17</option>
            <option>18</option>
            <option>19</option>
            <option>20</option>
            <option>21</option>
            <option>22</option>
            <option>23</option>
            <option>24</option>
            <option>25</option>
            <option>26</option>
            <option>27</option>
            <option>28</option>
            <option>29</option>
            <option>30</option>
            <option class="na">31</option>
            <option class="na">32</option>
            <option class="na">33</option>
        </select>
        <span></span>
    </div>
    <div class="fanghao">
        <select id="fanghao">
            <!-- <option selected="selected" disabled="disabled" style="display: none"></option> -->
            <option class="b">1</option>
            <option class="b">2</option>
            <option class="b">3</option>
            <option class="b">4</option>
            <option class="b">5</option>
            <option class="b">6</option>
            <option>7</option>
            <option>8</option>
            <option>9</option>
            <option>10</option>
            <option>11</option>
            <option>12</option>
            <option>13</option>
            <option>14</option>
            <option>15</option>
            <option>16</option>
            <option>17</option>
            <option>18</option>
            <option>19</option>
            <option>20</option>
        </select>
        <span></span>
    </div>
</div>

/ / key js code

// 
$("-sharpdanyuan option").hide()
var na = `<option class="na">31</option>
        <option class="na">32</option>
        <option class="na">33</option>`;
var nb = $("-sharpfanghao option:not(".b")").html()
$("-sharplouceng")[0].selectedIndex = -1;
$("-sharpfanghao")[0].selectedIndex = -1;
$("-sharpdong").change(function () {
    if ($("-sharpdong").val() == "A") {
        $("-sharpdanyuan")[0].disabled = true;
        $("-sharpdanyuan").css("background", "gray")
        // iOS
        $("-sharplouceng .na").remove()
        // $("-sharpfanghao option:not(".b")").remove()
        $("-sharpfanghao").append(nb)
        $("-sharplouceng")[0].selectedIndex = -1;
        $("-sharpfanghao")[0].selectedIndex = -1;
        $("-sharpdanyuan option").hide()
        $("-sharpdanyuan").val("")
    } else {
        $("-sharpdanyuan")[0].disabled = false;
        $("-sharpdanyuan").css("background", "-sharpfff")
        // iOS
        $("-sharplouceng").append(na)
        $("-sharpfanghao option:not(".b")").remove()
        $("-sharplouceng")[0].selectedIndex = -1;
        $("-sharpfanghao")[0].selectedIndex = -1;
        $("-sharpdanyuan option").show()
    }
})

what result do you expect? What is the error message actually seen?

the iOS version of Wechat has a pit and cannot set option to display:none. So I had to add and delete DOM by adding class names.
after the contents of this form are all my handwritten tags, I want to be able to implement them with a json configuration. Just tried the plug-in cxSelect, found that it is not easy to use, I would like to ask if there is a better way to achieve ideas and solutions?

Mar.28,2021

there is a hole for Wechat of the iOS version mentioned by the subject at the end, and option cannot be set to display:none. So I had to add and delete DOM by adding class names. I provide a solution to the problem: do not add or delete DOM, but use the method of setting width and height. For example, I want to hide an element and set its width and height to 0. This setting can be done by directly setting inline style or adding or deleting class,. This is all possible


$("-sharplouceng .na").hide(function () {
    $(this).width(0)
    $(this).height(0)
})

I tried it, but it didn't work, and the coupling is high. If the width and height of the select changes, it needs to be changed in three places.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bf11-2c2b7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bf11-2c2b7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?