dongtan7201 2013-02-22 13:51
浏览 58
已采纳

将重新排序的列表的顺序提交给我的服务器

Looking for a little help with this please:

I have implemented a drag & drop re-ordering feature in a survey i'm building, however i am unsure of how to submit the order of the list to my server once the user has re-ordered it.

Here is the JS for re-ordering:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<script>
$(function() {
$(  "#sortable"  ).sortable();
$(  "#sortable"  ).disableSelection();
});
</script>

and the html:

<ol id="sortable">
<li><label for=""><input type="checkbox" name="resortable-option1" value="1">Option 1</label></li>
<li><label for=""><input type="checkbox" name="resortable-option2" value="2">Option 1</label></li>
<li><label for=""><input type="checkbox" name="resortable-option3" value="3">Option 1</label></li>
<li><label for=""><input type="checkbox" name="resortable-option4" value="4">Option 1</label></li></ol>
  • 写回答

2条回答 默认 最新

  • duanmu5039 2013-02-22 14:25
    关注

    Here is an example using a form and submitting to PHP:

    action page:

     <?php
        if(isset($_POST["resortable-option"])){
           foreach($_POST["resortable-option"] as $item){
             echo $item."<br>";
           }
        }
     ?>
    

    HTML Form:

    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
    <script>
       $(function() {
          $(  "#sortable"  ).sortable();
          $(  "#sortable"  ).disableSelection();
       });
    </script>
    <form action="ActionPage" method="post">
       <ol id="sortable">
       <li><label for=""><input type="checkbox" name="resortable-option[]" value="1">Option 1</label></li>
       <li><label for=""><input type="checkbox" name="resortable-option[]" value="2">Option 2</label></li>
       <li><label for=""><input type="checkbox" name="resortable-option[]" value="3">Option 3</label></li>
       <li><label for=""><input type="checkbox" name="resortable-option[]" value="4">Option 4</label></li></ol>
       <input type="submit" value="send">
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度