Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.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 - Fatal编程技术网

Javascript 从表中提取以编辑模式窗体上的记录

Javascript 从表中提取以编辑模式窗体上的记录,javascript,jquery,Javascript,Jquery,我试图从表中提取数据到字段中,以编辑数据库中的记录 我使用下面的代码,但在Chrome控制台中我有一个js错误:$tr未定义 事实上,这行似乎有一个问题:$tr=$(this.nexist('tr') 当我打开modal时,我无法获取字段中的数据 有人帮我修吗 TXS 桌子 })) 模态 新的后续行动 您的文件中似乎有使用strict。它不允许在没有var、let或const 所以声明你的变量 通过var、let或const 在您的情况下,您不会更改变量值,因此const更可取 像 您的文件中

我试图从表中提取数据到字段中,以编辑数据库中的记录

我使用下面的代码,但在Chrome控制台中我有一个js错误:$tr未定义 事实上,这行似乎有一个问题:$tr=$(this.nexist('tr')

当我打开modal时,我无法获取字段中的数据

有人帮我修吗

TXS

桌子

}))

模态


新的后续行动

您的文件中似乎有
使用strict
。它不允许在没有
var
let
const

所以声明你的变量

通过
var
let
const

在您的情况下,您不会更改变量值,因此
const
更可取


您的文件中似乎有
使用strict
。它不允许在没有
var
let
const

所以声明你的变量

通过
var
let
const

在您的情况下,您不会更改变量值,因此
const
更可取


您是否尝试过使用
let$tr=$(this.closest('tr')?您的文件中似乎有
使用严格的
。它不允许您在没有
var
let
const
的情况下声明变量。Kenny与let一起工作,非常感谢您抽出时间!我补充一个答案。请接受它的答案,请张贴答案!您是否尝试过使用
let$tr=$(this.closest('tr')?您的文件中似乎有
使用严格的
。它不允许您在没有
var
let
const
的情况下声明变量。Kenny与let一起工作,非常感谢您抽出时间!我补充一个答案。请接受它的答案,请张贴答案!
<table class="table table-bordered table-dark">
    <thead>
        <tr>
            <th scope="col"> ID </th>
            <th scope="col"> Message</th>
            <th scope="col"> Button</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td><?php echo $opportunity_follow_up_id; ?></td>
            <td><?php echo $opportunity_follow_up_message; ?></td>
            <td><button type="button" class="btn btn-dark edit_followup">
                Edit Follow-up</button>
            </td>
        </tr>
    </tbody>
</table>
$(document).ready(function(){
    $(document).on('click', '.edit_followup', function(){ 
        $('#edit_followup').modal('show');
        alert ('working!');

        $tr = $(this).closest('tr');

        var data = $tr.children("td").map(function() {
            return $(this).text();
        }).get();

        console.log(data);

        $('#update_id').val(data[0]);
        $('#opportunity_follow_up_message').val(data[1]);

    });
<div class="modal fade text-left modal-borderless" id="edit_followup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel33" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
    <div class="modal-content">
    <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel33">New Follow-up </h4>
    </div>

    <form action="action/record_opportunities_follow_up.php" method="post" novalidate>

        <input type="hidden" id ="opportunity_follow_up_opportunities_id" name="opportunity_follow_up_opportunities_id" value="<?php echo $opportunities_id; ?>" />

            <div class="modal-body">
            <div class="form-group">
                <div class="controls">
                    <label>Follow-up Message</label>
                    <textarea data-length=250 class="form-control char-textarea" id="opportunity_follow_up_message" name="opportunity_follow_up_message"  rows="3" placeholder="*" required data-validation-required-message="Required"></textarea>
                    <small class="counter-value float-right"><span class="char-count">0</span> / 250 </small>
                </div>
            </div>

            <input type="hidden" name="update_id" id="update_id">
            <div class="form-group">   
                <div class="controls">
                    <label>Next follow-up Date</label>
                    <input type="text" id ="opportunity_follow_up_message" name="opportunity_follow_up_message" value="" placeholder="dd-mm-aaaa" class="form-control">
                </div>
            </div>
            <div class="form-group">        
                <div class="controls">
                    <label>Next follow-up Time</label>
                    <input type="text" id ="opportunity_follow_up_next_time" name="opportunity_follow_up_next_time" value="" placeholder="hh:mm:ss" class="form-control" data-mask="00:00:00">
                </div>
            </div>

            <div class="form-group">
                <div class="custom-control custom-checkbox">
                    <input type="checkbox" class="custom-control-input bg-primary" name="opportunity_follow_up_completed" id="opportunity_follow_up_completed" value="1">
                    <label class="custom-control-label" for="opportunity_follow_up_completed">Mark follow-up as complete</label>
                </div>
            </div>


        </div>

        <div class="modal-footer">
            <button type="submit" name="updatedata" value="save" class="btn btn-primary ml-1 block-page">
                <i class="bx bx-check d-block d-sm-none"></i>
                <span class="d-none d-sm-block">UPDATE</span>
            </button>
        </div>
    </form>
</div>
const $tr = $(this).closest('tr');