dp7311 2018-11-19 02:43
浏览 68

如何在php codeigniter中更改后获取表的td id值

The problem is whenever im drag & drop and replace td first place to another i have receiving that the replacement id in jquery. but the problem is how i can get that replacement td id value in php codeigniter. i just need if any of td of table has been exchange then i should knw which one is is replaced and get that id into my controller class of php codeigniter. thanks in advance.

$(document).ready(function () {

    $('tbody').addClass("DragMe");

    $('.DragMe').sortable({
        disabled: false,
        axis: 'y',
        items: "> tr:not(:first)",
        forceHelperSize: true,
        update: function (event, ui) {
            var Newpos = ui.item.index();
            var RefID = $('tr').find('td:first').html();


            //alert("Position " + Newpos + "..... RefID: " + RefID);
            $("#GridView1 tr:has(td)").each(function () {
                var RefID = $(this).find("td:eq(0)").html();
                var NewPosition = $("tr").index(this);
                alert(RefID + " " + NewPosition);
                $("#getpos").val(NewPosition);
                $("#ref").val(RefID);


            });

        }
    }).disableSelection();
});
<style type="text/css">
   .DragMe:Hover {
   cursor: move;
   }
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<!-- here is my view form -->
<form method="post" action="<?php echo base_url(); ?>index.php/dragcon/drag/dragfun">
   <table class="EU_DataTable" cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">
      <tbody>
         <tr>
            <th scope="col">Ref ID</th>
            <th scope="col">Issue relates to</th>
         </tr>
         <tr class="ui-sortable-handle">
            <td id="ref">9392</td>
            <td id="getpos">CRM</td>
         </tr>
         <tr class="ui-sortable-handle">
            <td id="ref">9394</td>
            <td id="getpos">CRM</td>
         </tr>
         <tr class="ui-sortable-handle">
            <td id="ref">9308</td>
            <td id="getpos">eMail</td>
         </tr>
         <tr class="ui-sortable-handle">
            <td id="ref">9342</td>
            <td id="getpos">Other</td>
         </tr>
         <tr class="ui-sortable-handle">
            <td id="ref">9365</td>
            <td id="getpos">CRM</td>
         </tr>
         <tr>
            <td><input type="submit" name="submit"></td>
         </tr>
      </tbody>
   </table>
</form>

As you seen where i can drag and drop td to td of table and also receiving in alert but i just want to get each of td value after change in the controller of php codeigniter thanks in advance.

</div>
  • 写回答

1条回答 默认 最新

  • duanruanxian5028 2018-11-19 02:57
    关注

    You need to look at the difference between client side and server side code. The action you perform in Javascript can not be passed to the original Codeigniter script as that script was already executed.

    In order to call back Codeigniter you want to use Ajax and in particular the Ajax functions of jQuery since you seem to be using that.

    It's a complex topic and you should study it in details to be sure you grasp the difference between server-side and client-side, when they happen and how they interact. If you want a more quick & dirty approach, this article from IBM seems perfect as it talks about Ajax, jQuery and CodeIgniter.

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型