Javascript Jquery-用数组填充下拉框的内容填充下拉框

Javascript Jquery-用数组填充下拉框的内容填充下拉框,javascript,jquery,Javascript,Jquery,当使用JQuery填充数据时,我有一个问题。 我有10个modal,ever modal是一个有infor的客户:选择1,数组$status=[8=>“return”,16=>“cancel”,17=>“processing”],选择第二个,第三个div是3个Select子映射,在Select parents处有3个键。 所以 如何选择父节点数据,然后隐藏3个div选择子节点 当分别单击Select child fill mapping和Select child处的1选项,并隐藏Select c

当使用JQuery填充数据时,我有一个问题。 我有10个modal,ever modal是一个有infor的客户:选择1,数组$status=[8=>“return”,16=>“cancel”,17=>“processing”],选择第二个,第三个div是3个Select子映射,在Select parents处有3个键。 所以

  • 如何选择父节点数据,然后隐藏3个div选择子节点
  • 当分别单击Select child fill mapping和Select child处的1选项,并隐藏Select child(例如:Select 1:-状态==8,fill and show div有Select 2的下拉列表1;status==16,fill and show下拉列表2,status==17,fill and show下拉列表3,Select 2
  • 列出项目并隐藏不相关的select。启动模式时,如果select 1有数据,状态==8,则只有select 2的列表1将显示与另一状态相同的数据(div 2,3将隐藏)。 非常感谢你的帮助
  • 当然:此处代码页视图:
    地位
    返回
    取消
    处理
    理由
    归还
    返回B
    取消
    取消B
    处理
    处理B
    
    请正确表述您的问题,并向我们展示您的代码,以便我们有更多的上下文。很抱歉,因为我的代码太长,所以我在下面发布。!希望使用JQuery。当我单击进入下拉列表返回时,然后使用元素Select name=“Reason\u Return”将数据填写到Reason中,类似于取消和处理。同时,当选择返回时(值=8)然后只显示val of和hide and.以及与另一个值16、17类似的值。与其在此处注释并将您的代码作为答案发布,不如将它们删除并添加到原始帖子中。否则将很难看到您的问题是否已解决。非常感谢,我的代码正在工作,因为帖子代码需要Ctrl+K才能显示答案但是错误很多次,然后我还没有发布!
    Certainly: Here code page view:
        <div class="form-group">
            <label>Status</label>
            <div class="col-md-3">
                <select class="form-control" id="status_pgd" name="status_pgd">
                    <option value="8">Return</option>
                    <option value="16">Cancel</option>
                    <option value="17">Processing</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label>Reason</label>
            <div class="show_reason_return">
                <select class="form-control" name="reason_return">
                    <option value="1">Return A</option>
                    <option value="2">Return B</option>
                </select>
            </div>
            <div class="show_reason_cancel">
                <select class="form-control" name="reason_cancel">
                    <option value="1">Cancel A</option>
                    <option value="2">Cancel B</option>
                </select>
            </div>
            <div class="show_reason_process">
                <select class="form-control" name="reason_process">
                    <option value="1">Processing A</option>
                    <option value="2">Processing B</option>
                </select>
            </div>
        </div>
    
    and here is code Jquery:`enter code here`
    $(document).ready(function () {
                $('#status_pgd').change(function () {
                    let status_pgd = $(this).val();
                    if (status_pgd == 8) {
                        $(".show_reason_return").show();
                        $(".show_reason_cancel").hide();
                        $(".show_reason_process").hide();
                    } else if (status_pgd == 16) {
                        $(".show_reason_cancel").show();
                        $(".show_reason_return").hide();
                        $(".show_reason_process").hide();
                    } else if (status_pgd == 17) {
                        $(".show_reason_process").show();
                        $(".show_reason_cancel").hide();
                        $(".show_reason_return").hide();
                    } else {
                        $(".show_reason_process").hide();
                        $(".show_reason_return").hide();
                        $(".show_reason_cancel").hide();
                    }
                });
            });
            $(document).ready(function () {
                let status_pgd1 = $('#status_pgd').val();
                if (status_pgd1 == 8) {
                    $(".show_reason_return").show();
                    $(".show_reason_cancel").hide();
                    $(".show_reason_process").hide();
                } else if (status_pgd1 == 16) {
                    $(".show_reason_cancel").show();
                    $(".show_reason_return").hide();
                    $(".show_reason_process").hide();
                } else if (status_pgd1 == 17) {
                    $(".show_reason_process").show();
                    $(".show_reason_cancel").hide();
                    $(".show_reason_return").hide();
                } else {
                    $(".show_reason_process").hide();
                    $(".show_reason_return").hide();
                    $(".show_reason_cancel").hide();
                }
            });