Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery-无法访问从一个列表框移动到另一个列表框的项目_Javascript_Jquery_Asp.net - Fatal编程技术网

Javascript jQuery-无法访问从一个列表框移动到另一个列表框的项目

Javascript jQuery-无法访问从一个列表框移动到另一个列表框的项目,javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我正在使用jQuery使用“添加”/“删除”按钮的单击事件将项目从一个列表框移动到另一个列表框。在屏幕上,我可以看到项目移动,但当我在代码中放置断点并在移动完成后检查内容时,我看不到移动的项目。这会影响服务器端处理,因为我无法获取正确的数据 <div class="row" id="zip"> <div class="col-sm-10 col-sm-offset-2" style="padding-left: 0px;"> <div cla

我正在使用jQuery使用“添加”/“删除”按钮的单击事件将项目从一个列表框移动到另一个列表框。在屏幕上,我可以看到项目移动,但当我在代码中放置断点并在移动完成后检查内容时,我看不到移动的项目。这会影响服务器端处理,因为我无法获取正确的数据

<div class="row" id="zip">
    <div class="col-sm-10 col-sm-offset-2" style="padding-left: 0px;">
        <div class="row">
            <div class="col-sm-4">
                <div class="form-group">
                    <label for="lbxUnassignedZips">All ZIPs</label>
                    <asp:ListBox runat="server" ID="lbxUnassignedZips" ClientIDMode="Static"></asp:ListBox>
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-group center-block text-center" style="margin: 0 -20px;">
                    <div class="form-group center-block" style="padding-top: 70px">
                        <button id="btnAddZip" type="submit" class="btn btn-default btn-block">Add&nbsp; <i class="fa fa-angle-double-right"></i></button>
                        <button id="btnRemoveZip" type="submit" class="btn btn-default btn-block"><i class="fa fa-angle-double-left"></i>&nbsp; Remove</button>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="form-group">
                    <label for="lbxAssignedZips">Assigned ZIPs</label>
                    <asp:ListBox runat="server" ID="lbxAssignedZips" ClientIDMode="Static"></asp:ListBox>
                </div>
            </div>
        </div>
        <!--/.row -->
    </div>
</div>
<button id="btnSubmit" class="btn btn-primary" aria-hidden="true" aria-label="Submit">Submit</button>

请看下面的代码。我已经更改了一些jQuery代码,现在您将拥有ListBox的所有项

$(document).on("click", "#btnSubmit", function (event) {
    var isValid = validateUpdateSubmit();

        if (isValid) {

            var assignedZips = [];

            $('#lbxUnassignedZips').children("option").each(function () {
                var $this = $(this);
                assignedZips.push($this.text() + "," + $this.val());
            });

            alert("AssignedZips  => " + lbxUnassignedZips.join());

            var lbxUnassignedZips = [];

            $('#lbxUnassignedZips').children("option").each(function () {
                var $this = $(this);
                lbxUnassignedZips.push($this.text() + "," + $this.val());
            });

            alert("AssignedZips  => " + lbxUnassignedZips.join());


        __doPostBack('btnubmit', "SaveUpdate");
        $('#editModal').modal('hide');

    }
    else
        return false;
        });

您能否在每个
表单组中发布包含一些实际内容的html,以便我们可以用代码片段重新创建问题?或者自己发布一个片段;)?
$(document).on("click", "#btnSubmit", function (event) {
    var isValid = validateUpdateSubmit();

        if (isValid) {

            var assignedZips = [];

            $('#lbxUnassignedZips').children("option").each(function () {
                var $this = $(this);
                assignedZips.push($this.text() + "," + $this.val());
            });

            alert("AssignedZips  => " + lbxUnassignedZips.join());

            var lbxUnassignedZips = [];

            $('#lbxUnassignedZips').children("option").each(function () {
                var $this = $(this);
                lbxUnassignedZips.push($this.text() + "," + $this.val());
            });

            alert("AssignedZips  => " + lbxUnassignedZips.join());


        __doPostBack('btnubmit', "SaveUpdate");
        $('#editModal').modal('hide');

    }
    else
        return false;
        });