使用PHP获取表的坐标并存储在数据库中

时间:2014-03-10 09:07:26

标签: php jquery mysql

我创建了一个页面,它有一些表格。我已经使这些表可拖动了,现在我需要在使用PHP移动到提供区域时存储表的坐标。请帮我解决这个问题,我无法理解。 html页面的代码是:

<table class="smsSecond"><!--bgcolor="#4ab54d"><class="smsSecond"--     this is td bgcolor: bgcolor="#4ab54d"-->
        <tr style="background-color: #3C3C3C;" >
             <td colspan="2" width="auto" align="center">Ticket Info<img id="delete" src="icons/delete.png" height="10" width="10" style="float: right;"/></td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center"><!-- style="color: #000000; font-size: 12px;"-->
            <td>
                Ticket number
            </td>
            <td>
                HFK-864-69976
            </td>
        </tr>


        <!--even row-->
        <tr class="evenrow" align="center"><!--style="color: #000000; font-size: 15px; background-color: #FFFFFF" --><!--background-color: #A4EAF6-->
            <td>
                Department
            </td>
            <td>
                Support
            </td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center">
            <td>
                Priority
            </td>
            <td>
                P3-Normal
            </td>
        </tr>

        <!--even row-->
        <tr class="evenrow" align="center">
            <td>
                Open Date and Time
            </td>
            <td>
                2011-02-28 21:24:01          
            </td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center">
            <td>
                Close Date and Time
            </td>
            <td>
                2011-02-28 21:24:01
            </td>
        </tr>

        <!--even row-->
        <tr class="evenrow" align="center">
            <td>
                Total Time
            </td>
            <td>
                00:03:09
            </td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center">
            <td>
                Ticket Spent
            </td>
            <td>
                00:02:00
            </td>
        </tr>

        <!--even row-->
        <tr class="evenrow" align="center">
            <td>
                No. of staff worked
            </td>
            <td>
                2
            </td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center">
            <td>
                Ticket Status
            </td>
            <td>
                Closed
            </td>
        </tr>

        <!--even row-->
        <tr class="evenrow" align="center">
            <td>
                SLA
            </td>
            <td>
                Yes
            </td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center">
            <td>
                Type
            </td>
            <td>
                Issue
            </td>
        </tr>

        <!--even row-->
        <tr class="evenrow" align="center">
            <td>
                Red Flag
            </td>
            <td>
                0
            </td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center">
            <td>
                Yellow Flag
            </td>
            <td>
                0
            </td>
        </tr>

        <!--even row-->
        <tr class="evenrow" align="center">
            <td>
                Orange Flag
            </td>
            <td>
                0
            </td>
        </tr>

        <!--odd row-->
        <tr class="oddrow" align="center">
            <td>
                Closed by
            </td>
            <td>
                Harsha p
            </td>
        </tr>
    </table>

使用的jquery是:

<script type="text/javascript">
      $(document).ready(function(){
        $(".smsSecond").draggable({containment: ".maincol"});//, revert: true

    $(".smsSecond").click(function(){
        $(this).hide(500);
    });

    $(document).bind("contextmenu", function(e) {

    $('.smsSecond').show(500);

    return false;

    });


});
    </script>

1 个答案:

答案 0 :(得分:0)

您可以使用offset

  

获取匹配集合中第一个元素的当前坐标   元素,相对于文档

var offset = $(".smsSecond").offset();
var left = offset.left; 
var top = offset.top;

根据您的需要,position也可能有用。