Php 从jQuery源数组访问数据?
ui设计师给了我这段代码,我不知道如何发布 选择源数组数据到一个php脚本,这样我就可以查询它与MySQL,我很抱歉我 作为JQuery的初学者,我想像查询表单选项select样式一样查询数组,还是使用关联数组更好Php 从jQuery源数组访问数据?,php,javascript,jquery,Php,Javascript,Jquery,ui设计师给了我这段代码,我不知道如何发布 选择源数组数据到一个php脚本,这样我就可以查询它与MySQL,我很抱歉我 作为JQuery的初学者,我想像查询表单选项select样式一样查询数组,还是使用关联数组更好 <div id='content'> <script type="text/javascript"> $(document).ready(function () { var source = [ "Selec
<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'>
如果您只需要使用这个奇特的下拉菜单作为普通下拉菜单,下面是一个不需要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>
下载并使用jqwidgets库。
将选择事件绑定到jqwidgets下拉列表,该下拉列表将所选值放入普通隐藏表单元素。
提交并在PHP中作为正常提交值使用
更多信息:需要使用ajax或json!请点击此处:http://stackoverflow.com/questions/1968296/how-to-i-send-data-from-javascript-to-php-and-vice-versajust 我去看看,谢谢