Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
编写jquerydrag&;将所选内容放入PHP变量中_Php_Jquery Ui_Drag And Drop_Jquery Ui Draggable_Jquery Ui Droppable - Fatal编程技术网

编写jquerydrag&;将所选内容放入PHP变量中

编写jquerydrag&;将所选内容放入PHP变量中,php,jquery-ui,drag-and-drop,jquery-ui-draggable,jquery-ui-droppable,Php,Jquery Ui,Drag And Drop,Jquery Ui Draggable,Jquery Ui Droppable,我已经实现了图像拖放,如以下示例所示:。我为每个图像元素添加了ID,这样我就可以创建一个被破坏元素的列表,并为未被破坏的元素创建另一个列表 我真的需要一些帮助来将选中和未选中的id输入PHP 删除发生后的变量 启动id为的UL gallery(可拖动)图像元素,例如: <ul id="gallery" class="gallery ui-helper-reset ui-helper-clearfix"> <li class="ui-widget-content ui

我已经实现了图像拖放,如以下示例所示:。我为每个图像元素添加了ID,这样我就可以创建一个被破坏元素的列表,并为未被破坏的元素创建另一个列表

我真的需要一些帮助来将选中和未选中的id输入PHP 删除发生后的变量

启动id为的UL gallery(可拖动)图像元素,例如:

  <ul id="gallery" class="gallery ui-helper-reset ui-helper-clearfix">
    <li class="ui-widget-content ui-corner-tr">
      <img src="img/gler.png" alt="lake" width="96" height="32" id="2">
      <a href="link/to/trash/script/when/we/have/js/off" title="Delete this image" class="ui-icon ui-icon-trash">Delete image</a>
    </li>
  </ul>
垃圾箱分区(可下降)


垃圾

使用javascript,您需要在每个容器中构建一个ID数组,如下所示:

var selected = [],
    unselected = [];
$('#gallery img').each(function(){
    selected.push($(this.attr('id'));
});
$('#trash img').each(function(){
    unselected.push($(this.attr('id'));
});

您可以使用事件触发此操作,例如每次拖放后或用户单击“完成”按钮时,等等。现在,您可以随意将这些数组传递给服务器(刷新页面或ajax调用)。

嗨,Joe42,我在这里迷路了。。。我将脚本声明为:
$(document).ready(function(){$('#MyButton')。click(function(){var selected=[],unselected=[];$('#gallery img')。each(function(){selected.push($(this.attr('id'));$)('#trash img')。each(function(){unselected.push($(this.attr('id'));));})
和一个按钮,如:
如果可以的话,您能帮我将数组传递给字符串吗?提前谢谢,非常抱歉。
var selected = [],
    unselected = [];
$('#gallery img').each(function(){
    selected.push($(this.attr('id'));
});
$('#trash img').each(function(){
    unselected.push($(this.attr('id'));
});