ui设计师给了我这个代码,我不知道如何发布 选择源数组数据到PHP脚本所以我可以用MySQL查询它,对不起我 一个JQuery的初学者,我想像一个表单选项选择样式一样查询数组,或者使用关联数组会更好吗?
<div id='content'>
<script type="text/javascript">
$(document).ready(function () {
var source = [
"Select Your location",
"North London",
"South London",
"West London",
"East London",
"City of London",
];
// Create a jqxDropDownList
$("#jqxDropDownList").jqxDropDownList({
source: source,
selectedIndex: 0,
width: '250px',
height: '35px',
theme: 'summer'
});
});
</script>
<div id='jqxDropDownList'>
答案 0 :(得分:2)
如果你只需要将这个花哨的下拉列表用作正常的下拉列表,这里就是一个例子(不需要ajax):
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="jqwidgets/jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="jqwidgets/jqwidgets/jqxlistbox.js"></script>
<script type="text/javascript" src="jqwidgets/jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="jqwidgets/jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="jqwidgets/jqwidgets/jqxdropdownlist.js"></script>
</head>
<body>
<div id='content'>
<script type="text/javascript">
$(document).ready(function () {
var source = [
"Select Your location",
"North London",
"South London",
"West London",
"East London",
"City of London",
];
// Create a jqxDropDownList
$("#jqxDropDownList").jqxDropDownList({
source: source,
selectedIndex: 0,
width: '250px',
height: '35px',
theme: 'summer'
});
$('#jqxDropDownList').bind('select', function (event) {
$('#location').val($("#jqxDropDownList").jqxDropDownList('getSelectedItem').label);
});
});
</script>
<div id='jqxDropDownList'></div>
<form>
<input type="text" id="location" name="location" value="not selected" />
<input type="submit" value="selected!">
</form>
<div><?php if (isset($_GET['location'])) print('You selected: '.$_GET['location']); ?></div>
</div>
</body>
</html>