使用拖放功能后生成文本文件

时间:2014-03-06 20:10:50

标签: php jquery html css drag-and-drop

我试图在拖放各个位置的元素时生成文本文件。

您可以查看我的代码http://jsfiddle.net/4r4g3/

<script src='https://raw.github.com/dbunic/REDIPS_drag/master/redips-drag-min.js'></script>
<body onload="REDIPS.drag.init()">
<div id="drag">
    <table style='width: 100%;' cellpadding=5 cellspacing=5 id="table1">
        <tr>
            <td colspan=13 class='bk'><b>File Generator</b>
            </td>
        </tr>
        <tr>
            <td></td>
            <td class='bk'>1</td>
            <td class='bk'>2</td>
            <td class='bk'>3</td>
            <td class='bk'>4</td>
            <td class='bk'>5</td>
            <td class='bk'>6</td>
            <td class='bk'>7</td>
            <td class='bk'>8</td>
            <td class='bk'>9</td>
            <td class='bk'>10</td>
            <td class='bk'>11</td>
            <td class='bk'>12</td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button0 value=A>
            </td>
            <td id='go0' id="d1">
                <div class="drag" id="d2">CL-1004</div>
            </td>
            <td id='go1'>
                <div class="drag" id="d3">CL-1005</div>
            </td>
            <td id='go2'>
                <div class="drag" id="d4">CL-1006</div>
            </td>
            <td id='go3'>
                <div class="drag">OK</div>
            </td>
            <td id='go4'>
                <div class="drag">NOT OK</div>
            </td>
            <td class='none' id='go5'></td>
            <td class='none' id='go6'></td>
            <td class='none' id='go7'></td>
            <td class='none' id='go8'></td>
            <td class='none' id='go9'></td>
            <td class='none' id='go10'></td>
            <td class='none' id='go11'></td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button1 value=B>
            </td>
            <td class='none' id='go12'></td>
            <td class='none' id='go13'></td>
            <td class='none' id='go14'></td>
            <td class='none' id='go15'></td>
            <td class='none' id='go16'></td>
            <td class='none' id='go17'></td>
            <td class='none' id='go18'></td>
            <td class='none' id='go19'></td>
            <td class='none' id='go20'></td>
            <td class='none' id='go21'></td>
            <td class='none' id='go22'></td>
            <td class='none' id='go23'></td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button2 value=C>
            </td>
            <td class='none' id='go24'></td>
            <td class='none' id='go25'></td>
            <td class='none' id='go26'></td>
            <td class='none' id='go27'></td>
            <td class='none' id='go28'></td>
            <td class='none' id='go29'></td>
            <td class='none' id='go30'></td>
            <td class='none' id='go31'></td>
            <td class='none' id='go32'></td>
            <td class='none' id='go33'></td>
            <td class='none' id='go34'></td>
            <td class='none' id='go35'></td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button3 value=D>
            </td>
            <td class='none' id='go36'></td>
            <td class='none' id='go37'></td>
            <td class='none' id='go38'></td>
            <td class='none' id='go39'></td>
            <td class='none' id='go40'></td>
            <td class='none' id='go41'></td>
            <td class='none' id='go42'></td>
            <td class='none' id='go43'></td>
            <td class='none' id='go44'></td>
            <td class='none' id='go45'></td>
            <td class='none' id='go46'></td>
            <td class='none' id='go47'></td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button4 value=E>
            </td>
            <td class='none' id='go48'></td>
            <td class='none' id='go49'></td>
            <td class='none' id='go50'></td>
            <td class='none' id='go51'></td>
            <td class='none' id='go52'></td>
            <td class='none' id='go53'></td>
            <td class='none' id='go54'></td>
            <td class='none' id='go55'></td>
            <td class='none' id='go56'></td>
            <td class='none' id='go57'></td>
            <td class='none' id='go58'></td>
            <td class='none' id='go59'></td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button5 value=F>
            </td>
            <td class='none' id='go60'></td>
            <td class='none' id='go61'></td>
            <td class='none' id='go62'></td>
            <td class='none' id='go63'></td>
            <td class='none' id='go64'></td>
            <td class='none' id='go65'></td>
            <td class='none' id='go66'></td>
            <td class='none' id='go67'></td>
            <td class='none' id='go68'></td>
            <td class='none' id='go69'></td>
            <td class='none' id='go70'></td>
            <td class='none' id='go71'></td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button6 value=G>
            </td>
            <td class='none' id='go72'></td>
            <td class='none' id='go73'></td>
            <td class='none' id='go74'></td>
            <td class='none' id='go75'></td>
            <td class='none' id='go76'></td>
            <td class='none' id='go77'></td>
            <td class='none' id='go78'></td>
            <td class='none' id='go79'></td>
            <td class='none' id='go80'></td>
            <td class='none' id='go81'></td>
            <td class='none' id='go82'></td>
            <td class='none' id='go83'></td>
        </tr>
        <tr>
            <td class='bk'>
                <input type=button id=button7 value=H>
            </td>
            <td class='none' id='go84'></td>
            <td class='none' id='go85'></td>
            <td class='none' id='go86'></td>
            <td class='none' id='go87'></td>
            <td class='none' id='go88'></td>
            <td class='none' id='go89'></td>
            <td class='none' id='go90'></td>
            <td class='none' id='go91'></td>
            <td class='none' id='go92'></td>
            <td class='none' id='go93'></td>
            <td class='none' id='go94'></td>
            <td class='none' id='go95'></td>
          </tr>
       </table>
   </div>
</body>

我的CSS代码:

body {
font-size: 10pt;
}
th, td {
font-size: 9pt;
border: 1px solid black;
width: 7.6%;
text-align: center;
vertical-align: middle;
}
td.bk {
  background: #4B545C;
color: white;
}
td.none {
background: #B8B8B8;
color: #B8B8B8;
 }
td.bottom {
border: 1px 1px 0px 0px solid black;
text-align: left;
vertical-align: bottom;
}
.yellow {
background: #FFF394;
}
.bblue {
background: #94A0FF;
 }
.dark {
background: Blue;
color: #ffffff;
 }
.noborder {
border: 0px;
 }
 .right {
text-align: right !important;
}
.drag {
margin: auto;
text-align: center;
width: 76;
border: 0px;
color: black;
 }

结构采用表格格式。我能够将id拖放到表格的任何位置。

但是一旦表格组织良好,当我尝试使用表格id或div id生成文本文件时,我能够获得td中给出的ID的值,但我正在寻找丢弃在不同地方的元素

这是我用来获取元素位置的代码(如第5行单元格6)但是我怎样才能获得分配给不同td的值(CL-1004等)。

<html>
<head>
<style>body{font-family:Verdana,Arial,Helvetica,sans-serif;}</style>
</head>
 <body>
<b>Query string</b>
<br/>
<?php print($_SERVER['QUERY_STRING']) ?>
<br/>
<br/>
<b>Accepted parameters:</b>
<br/>
<?php
    // accept parameters (p is array)
    $arr = $_REQUEST['p'];
    // open loop through each array element
    foreach ($arr as $p){
        // detach values from each parameter
        list($id, $row, $cell) = explode('_', $p);
        // instead of print, you can store accepted parameteres to the database
        print "Id=$id Row=$row Cell=$cell<br>";
    }
?>
</body>
</html>

我希望我的文本文件格式如下。

   CL-1004 A01
   CL-1005 A02
   CL-1005 A03
   Ok A04
   NOT OK A05

真的很感激任何帮助。

0 个答案:

没有答案