可选择的Jquery和php
Selectable Jquery and php
我正在寻找一种方法来发送选定的项目到一个可选的Jquery到php页面
<script>
$(function() {
$( "#selectable" ).selectable({
stop: function() {
var result = $( "#select-result" ).empty();
$( ".ui-selected", this ).each(function() {
var index = $( "#selectable li" ).index( this );
result.append( " #" + ( index + 1 ) );
});
}
});
});
$(function() {
$("#foo").submit(function(event){
$.post('batch.php?page=rinomina', {selectable: $('#select-result').html()});
});
});
</script>
<script>
$(function() {
$( ".direct" )
.button()
.click(function( event ) {
});
});
</script>
<form id="foo" action="" method="post">
<a href="javascript:{}" class="direct"onclick="document.getElementById('foo').submit(); return false;">submit</a>
但它是错误的,不明白我错在哪里!
我不太明白。看起来您想要的是将每个选定列表项的索引号作为参数发送给php方法?你可以用很多方法来解决这个问题。我能想到的最简单的方法是获取所选内容的索引,然后使用jQuery的param方法使它们对URL友好,并添加到您的帖子URL中。例如:
$(function() {
$("#selectable").selectable();
$("#foo").submit(function(e) {
e.preventDefault();
var ids = new Array();
$("#selectable .ui-selected").each(function(i) { ids[i] = "# " + ($(this).index()+1); });
// get values as URL parameters for passing to PHP
var paramSelectable = $.param({ selectable: ids });
// easiest implementation with what you have
$.post('batch.php?page=rinomina&'+paramSelectable);
});
})
$(function() {
$("#selectable").selectable();
$("#foo").submit(function(e) {
e.preventDefault();
var ids = new Array();
$("#selectable .ui-selected").each(function(i) { ids[i] = "# " + ($(this).index()+1); });
// get values as URL parameters for passing to PHP
var paramSelectable = $.param({ selectable: ids });
// easiest implementation with what you have
$.post('batch.php?page=rinomina&'+paramSelectable);
});
})
相关文章:
- PHP/JQUERY-显示json的每个子数组
- 如何避免试图用php+jquery显示php起始页的无限循环
- PHP Jquery选项卡:内容加载到一个选项卡's面板
- onClick按钮不工作javascript/php/jquery mobile
- URL PHP/jQuery的链接预览
- 使用 php/jquery 动态更新单个模态
- PHP jQuery使用多个单词传递值
- PHP/JQUERY定义包含的页面
- PHP/Jquery-在PHP函数中呼应Jquery
- PHP-Jquery-简单模式的开放数据
- (php/jquery)根据另一个选中的复选框值隐藏和显示复选框
- 添加<tr>元素到动态表,动态不刷新页面,php-jquery
- 意外的PHP/jQuery/JSON交互差异
- jqgrid子网格row_id空格不起作用PHP jquery
- 如何使用PHP jquery和ajax从MySQL中检索多个值
- 在单击PHP / Jquery时更新附加的变量
- PHP JQuery 对话框和数据表 + 丢失布局
- 背景图像旋转器.php + jQuery每4秒显示一次随机照片
- php/jquery buffer full ?页面未完全加载
- 使用 ajax 拖放功能对列字段重新排序?PHP/jQuery.