Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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 $()。每个(函数()未获取正确的动态数据_Javascript_Jquery_Codeigniter_Each - Fatal编程技术网

Javascript $()。每个(函数()未获取正确的动态数据

Javascript $()。每个(函数()未获取正确的动态数据,javascript,jquery,codeigniter,each,Javascript,Jquery,Codeigniter,Each,我有一个现有表,其中的数据来自中的数据库。如果我想单击“添加”按钮或按Enter键,它应该追加一个新行 在新添加的行中输入数据后,我会将其与现有数组或以前在同一表中添加的数据进行比较。如果数组或同一表中存在现有数据,将保持为空,直到我输入唯一的数据并自动追加新行,依此类推 目前,只有第一个Enter键在工作 这是我的HTML: <table id="datatable-boxes" class="table table-hover table-bordered table-striped

我有一个现有表,其中的数据来自
中的数据库。如果我想单击“添加”按钮或按Enter键,它应该追加一个新行

在新添加的行中输入数据后,我会将其与现有数组或以前在同一表中添加的数据进行比较。如果数组或同一表中存在现有数据,
将保持为空,直到我输入唯一的数据并自动追加新行,依此类推

目前,只有第一个Enter键在工作

这是我的HTML:

<table id="datatable-boxes" class="table table-hover table-bordered table-striped forex-datatable">
    <thead>
        <tr>
            <th>Courier Tracking #</th>
            <th>Courier</th>
            <th>Vendor</th>
            <th width="20%">Action</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><input type="text" form="edit-boxes-form" class="form-control input-sm retrieve_track_no from_db" name="retrieve_courier_tracking_no[]" id="retrieve_courier_tracking_no_1" value="4987176601285" /></td>
            <td><input type="text" form="edit-boxes-form" class="form-control input-sm from_db" name="retrieve_courier_name[]" id="retrieve_courier_name_1" value="Philpost" /></td>
            <td><input type="text" form="edit-boxes-form" class="form-control input-sm from_db" name="retrieve_vendor_name[]" id="retrieve_vendor_name_1" value="Ebay" /></td>
            <td class="box-action"><button class="btn btn-danger btn-xs clear-data" data-toggle="tooltip" data-toggle="modal" title="Delete Box data" data-target="#delete_box_modal_1"><span class='glyphicon glyphicon-trash' aria-hidden="true"></span></button></td>
        </tr>
    </tbody>
</table>
按enter键生成第三行后,警报如下:

4987176601285
*blank*
*blank*
eto na yun
我不确定为什么我新输入的数据没有被提取。非常感谢您的帮助。谢谢!

我用
filter()
更改了我的
each()
函数。我不完全确定为什么这一个有效,而另一个无效

$('#datatable-boxes input[name^="retrieve_courier_tracking_no[]"]').filter(function() {
            value = $(this).val();
            ret_found = findItem(boxes_array, value);
            if (existing.indexOf(value) >= 0) {
                // console.log($(this).val());
                ret_checker = false;
                if(ret_found){
                    $('.alert-batch-box-data').css('display', 'visible');
                    $('.alert').append('<p class="text-left"><strong>'+value+'</strong> already exists in Batch # <strong>'+ret_found.batch_no+'</strong>.</p>');
                } else if((ret_checker == false) && (!ret_found)){
                    frontend_duplicate = true;
                    if($(this).val() == ''){
                        frontend_duplicate = false; 
                    }
                } else {
                    frontend_duplicate = false;
                }
                $(this).val('');
            } else {
                ret_checker = true;
                frontend_duplicate = false
            }
            existing.push(value);
        });
$('#数据表框输入[name^=“retrieve_courier_tracking_no[]”)。过滤器(函数(){
value=$(this.val();
ret_found=findItem(框数组,值);
if(现有的indexOf(值)>=0){
//log($(this.val());
ret_checker=false;
如果(重新找到){
$('.alert batch box data').css('显示','可见');
$('.alert').append('

'+value+'已存在于批处理中。'+ret\u已找到。批处理编号+'

'); }否则如果((ret_checker==false)和(!ret_found)){ 前端重复=真; if($(this.val()=''){ 前端重复=错误; } }否则{ 前端重复=错误; } $(this.val(“”); }否则{ ret_checker=真; 前端重复=错误 } 现有。推送(价值); });

然后我修改了它以适应我以前的代码。

提供了一个实际的html示例。您的php对调试前端毫无用处。请参阅删除了我的php标记@charlietfl.demobiles@wolfgang1983。它们是我的codeigniter站点的代码片段吗?
4987176601285
*blank*
*blank*
eto na yun
$('#datatable-boxes input[name^="retrieve_courier_tracking_no[]"]').filter(function() {
            value = $(this).val();
            ret_found = findItem(boxes_array, value);
            if (existing.indexOf(value) >= 0) {
                // console.log($(this).val());
                ret_checker = false;
                if(ret_found){
                    $('.alert-batch-box-data').css('display', 'visible');
                    $('.alert').append('<p class="text-left"><strong>'+value+'</strong> already exists in Batch # <strong>'+ret_found.batch_no+'</strong>.</p>');
                } else if((ret_checker == false) && (!ret_found)){
                    frontend_duplicate = true;
                    if($(this).val() == ''){
                        frontend_duplicate = false; 
                    }
                } else {
                    frontend_duplicate = false;
                }
                $(this).val('');
            } else {
                ret_checker = true;
                frontend_duplicate = false
            }
            existing.push(value);
        });