【问题标题】:Change a dropbox contend selecting another dropbox更改 Dropbox 竞争选择另一个 Dropbox
【发布时间】:2015-06-08 15:31:57
【问题描述】:

我有一个保管箱:

        <div class="control-group">
            <label class="control-label" for="SORD_DREVIZ">Actul*</label>
            <div class="controls">
                <select style="width: 200px;max-width: 200px;" name="metadataValues['SORD_DREVIZ']" id="SORD_DREVIZ" class="required">
                    <option value=""></option>
                    <c:forEach items="${comboItemsMap4['SORD_DREVIZ']}" var="comboItem">
                        <option value="${comboItem.objId}" <c:if test="${comboItem.objId eq document.metadataValues['SORD_DREVIZ']}">selected="selected"</c:if>>${comboItem.regNumber} / ${comboItem.regDate.month}-${comboItem.regDate.day}-${comboItem.regDate.year}</option>
                    </c:forEach>
                </select>
                <input type="checkbox" id="ACT_INEXISTENT"/> Actul nu exista in sistem
            </div>
        </div>

还有一个:

    <div class="control-group">
        <label class="control-label" for="TIPUL_ACTULUI_REGLEMENTARE">Tipul actului de reglementare*</label>
        <div class="controls">
            <select style="width: 400px;max-width: 400px;" name="metadataValues['TIPUL_ACTULUI_REGLEMENTARE']" id="TIPUL_ACTULUI_REGLEMENTARE" class="required">
                <option value=""></option>
                <c:forEach items="${comboItemsMap['TIPUL_ACTULUI_REGLEMENTARE']}" var="comboItem">              
                    <option value="${comboItem.value}" <c:if test="${comboItem.value eq document.metadataValues['TIPUL_ACTULUI_REGLEMENTARE']}">selected="selected"</c:if>>${comboItem.text}</option>
                </c:forEach>
            </select>                           
        </div>
    </div>  

当我更改第二个 Dropbox 时,我想更改第一个 Dropbox 的内容:

$("#TIPUL_ACTULUI_REGLEMENTARE").change(function(){
        var selectedText = $(this).find("option:selected").text();
        $.ajax({
            type:'POST',
            url: '<c:url value="/cerere/searchByAct"/>',
            data:{act:selectedText},
            dataType: 'json',
            context:this,
            success:function(data){
                console.log(data);
                //TODO - change the SORD_DREVIZ combo - I have in data what I need from server side

            },
            error:function(xmlHttpRequest, textStatus, errorThrown){
                if(xmlHttpRequest.readyState=0 || xmlHttpRequest.status == 0)
                    return;
            }
        });
    });

我该怎么做? 我有这样的数据:

[Object { objId=626984, regDate=1426370400000, regNumber="333"}]

我的组合应该看起来像 333 / 03-15-2015

谢谢!

【问题讨论】:

    标签: jquery ajax select drop-down-menu


    【解决方案1】:

    好的,我是这样做的,但我不知道如何将 Julian 日期转换为 mm-dd-yyyy。

    var selectedText = $(this).find("option:selected").text();
            $.ajax({
                type:'POST',
                url: '<c:url value="/cerere/searchByAct"/>',
                data:{act:selectedText},
                dataType: 'json',
                context:this,
                success:function(data){
                    $('#SORD_DREVIZ').empty();
                    $(data.slSordIdRegInfo).each(function()
                    {
                        console.log(this.regDate);
                        var option = $('<option />');
                        option.attr('value', this. objId).text(this.regNumber);
                        $('#SORD_DREVIZ').append(option);
                    });
                },
                error:function(xmlHttpRequest, textStatus, errorThrown){
                    if(xmlHttpRequest.readyState=0 || xmlHttpRequest.status == 0)
                        return;
                }
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-29
      • 1970-01-01
      • 1970-01-01
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多