Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.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
Php Javascript、jQuery和Ajax新手_Php_Jquery_Javascript Events - Fatal编程技术网

Php Javascript、jQuery和Ajax新手

Php Javascript、jQuery和Ajax新手,php,jquery,javascript-events,Php,Jquery,Javascript Events,好的-我已经了解了如何使用jquery拖放可排序ui。我还了解了如何使用表中的时间数据填充jquery列表。但是我碰到了另一堵砖墙 下面是test.php的脚本 <?php session_start(); // include database connection file, if connection doesn't work the include file will throw an error message include '../schedule/include/db_co

好的-我已经了解了如何使用jquery拖放可排序ui。我还了解了如何使用表中的时间数据填充jquery列表。但是我碰到了另一堵砖墙

下面是test.php的脚本

<?php
session_start();
// include database connection file, if connection doesn't work the include file will throw an error message
include '../schedule/include/db_connect.php';

    $date1 = "10/01/2012";
        echo $date1;

// strtotime() will convert nearly any date format into a timestamp which can be used to build a date with the date() function.
$timestamp = strtotime($date1);
$start_date = date("Y-m-d", $timestamp);

$result="SELECT DATE_FORMAT(List_Dates.DB_Date, '%m/%d/%Y') as newdate, DATE_FORMAT(List_Time.TFM_Time,'%h:%i %p') as newtime
FROM List_Dates, List_Time
WHERE DATE(DATE_FORMAT(List_Dates.DB_Date,'%Y-%m-%d')) LIKE '" . $start_date . "%'
ORDER BY List_Time.TFM_Time";

$answer = mysql_query($result);

?>
<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8">
        <title>jQuery UI Sortable - Connect lists</title>
        <link rel="stylesheet" type="text/css" href="../schedule/include/formats.css"/>
        <link rel="stylesheet" href="../jquery/themes/custom-theme/jquery.ui.all.css">
        <script src="../jquery/jquery-1.7.1.js"></script>
        <script src="../jquery/ui/jquery.ui.core.js"></script>
        <script src="../jquery/ui/jquery.ui.widget.js"></script>

        <script src="../jquery/ui/jquery.ui.mouse.js"></script>
        <script src="../jquery/ui/jquery.ui.sortable.js"></script>
        <script src="../jquery/ui/jquery.ui.selectable.js"></script>
        <style>
        #sortable1, #sortable2 { list-style-type: none; margin: 0; padding: 0 0 2.5em; float: left; margin-right: 10px; }
        #sortable1 li, #sortable2 li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; }
        </style>
        <script>
        $(function() {
                $( "#sortable1, #sortable2" ).sortable({
                        connectWith: ".connectedSortable"
                }).disableSelection();
        });
        </script>
</head>
<body>

<div>
<ul name="timelist" id="sortable1" class="connectedSortable">
<?php
while($row = mysql_fetch_array($answer))
{
        echo "<li class='ui-state-default'>". $row['newtime'] ."</li>";
}
?>
</ul>

<ul name="blocklist" id="sortable2" class="connectedSortable">
        <li id="blocked" type="date" class="ui-state-highlight"></li>
</ul>
</div>

</body>
</html>
正如我前面提到的,该脚本正在成功地用我的数据库中的时间填充一个可排序的拖放列表。我可以从左侧时间列表拖放一次到右侧区块列表。现在我需要从区块列表中提取一个数组。我发现:

<script>
$('ul#myList li').each(function(){
var number = $(this).find('span:first-child').text();
var fruit = $(this).find('span:first-last').text();
});
</script>
对于我的应用程序,按如下方式更改语法是有意义的:

<script>
$('ul#sortable2 li').each(function(){
var btime = $(this).find('span:first-child').text();
});
</script>
但是。。。我不知道如何成功地使用它并响应结果。我所做的一切都失败了。欢迎任何建议


非常感谢-Pavilion

查看jQuery UI文档有一个名为toArray的方法,您可以调用可排序元素来获取数组