在bootstrap模式中从backup表中读取一次值

问题描述 投票:-1回答:1

我试图通过表格模态显示从表中读取值。我无法从模态背后的表中获得价值。有什么具体规定吗?

我究竟做错了什么?想要读取支持的表字段的值,并希望用于计算模态字段。

请在这里查看示例 - Sample Code

/*doesn't read value of rollno from table when modal input box on change*/
$('#frm_name').change(function() {
  var $row = $(this).closest('tr');
  var rowID = $row.attr('class').split('_')[1];
  var rollno = $row.find('.td_rollno').text();
  alert(rollno);
});

HTML

<table class="table table-responsive">
  <thead>
    <tr>
      <th>NAME</th>
      <th>ROLL NUMBER</th>
      <th>CONTACT NO</th>
      <th>ADDRESS</th>
      <th>EDIT</th>
    </tr>
  </thead>
  <tbody>
    <tr class="trID_1">
      <td class="td_name">Name Row1</td>
      <td class="td_rollno">12345</td>
      <td class="td_contact">Mickey Mouse</td>
      <td class="td_address">123 Mouse Lane</td>
      <td>
        <button class='td_btn btn btn-link btn-custom dis'>EDIT</button>
      </td>
    </tr>
    <tr class="trID_2">
      <td class="td_name">Name Row2</td>
      <td class="td_rollno">22222</td>
      <td class="td_contact">Wiley Coyote</td>
      <td class="td_address">RR3 Road Runner Lane</td>
      <td>
        <button class='td_btn btn btn-link btn-custom dis'>EDIT</button>
      </td>
    </tr>
    <tr class="trID_3">
      <td class="td_name">Name Row3</td>
      <td class="td_rollno">33333</td>
      <td class="td_contact">Pepe LePew</td>
      <td class="td_address">88 Stink Street</td>
      <td>
        <button class='td_btn btn btn-link btn-custom dis'>EDIT</button>
      </td>
    </tr>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">EDIT RECORD</h4>
      </div>
      <div class="modal-body">

        <form id="updateValues" action="update.php" method="POST" class="form">
          <div class="form-group">
            <label for="name">NAME</label>
            <input type="text" class="form-control" name="name" id="frm_name">
          </div>
          <div class="form-group">
            <label for="contact">CONTACT</label>
            <input type="text" class="form-control" name="contact" id="frm_contact">
          </div>
          <div class="form-group">
            <label for="address">ADDRESS</label>
            <textarea class="form-control" rows="3" name="address" id="frm_address"></textarea>
          </div>
          <input type="hidden" name="frm_id">
          <input type="submit" class="btn btn-primary btn-custom" value="Save changes">
        </form>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <div id="results"></div>
      </div>

    </div>
javascript jquery html twitter-bootstrap
1个回答
1
投票

您的标记建议尝试使用发布到update.php的模式表单更新记录。另外,你有一个jQuery函数,看起来像尝试用模态输入更新表内容。

如果我理解正确,您将需要阅读特定PHP框架的文档,以了解如何:

  • 通过AJAX提交表单
  • 使用将相应更新DOM的脚本处理成功更新
© www.soinside.com 2019 - 2024. All rights reserved.