如何从可在PHP中选择的jQuery UI获取值 [英] How to get the value from jQuery UI selectable in php
本文介绍了如何从可在PHP中选择的jQuery UI获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我创建了此列表,当您使用jQuery UI的selectable选择一个项目时,它会更改颜色.
Hello I have created this list which changes the colour when you select an item using jQuery UI's selectable.
<ol id="selectable">
<li class="ui-widget-content" Name ='gender' value= 'male1'>Item 1</li>
<li class="ui-widget-content" Name ='gender' value= 'male2'>Item 2</li>
<li class="ui-widget-content" Name ='gender' value= 'male3'>Item 3</li>
<li class="ui-widget-content" Name ='gender' value= 'male4'>Item 4</li>
<li class="ui-widget-content" Name ='gender' value= 'male5'>Item 5</li>
<li class="ui-widget-content" Name ='gender' value= 'male6'>Item 6</li>
<li class="ui-widget-content" Name ='gender' value= 'male7'>Item 7</li>
</ol>
<Input type = "Submit" Name = "Submit1" VALUE = "Select a Radio Button">
我如何在php文件中发送/获取所选项目?
Ho do I send/get the selected item in a php file?
推荐答案
$(function() {
$( "#selectable" ).selectable({
stop: function() {
var result = $( "#select-result" ).empty();
$( ".ui-selected", this ).each(function() {
var index = $( "#selectable li" ).index( this );
// send an AJAX request to a PHP file
$.get('myphpfile.php', {
selectedIndex: index
}, function(data) {
// do stuff with the results from PHP
});
});
}
});
});
编辑
要通过按钮执行此操作
$(function() {
$( "#selectable" ).selectable();
$("submit[name=Submit1]").click(function() {
var index = $( "#selectable li" ).index( $("#selectable") );
$.get('myphpfile.php', {
selectedIndex: index
}, function(data) {
// do stuff with the results from PHP
});
});
});
这篇关于如何从可在PHP中选择的jQuery UI获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文