我想创建一个三重嵌套选择,但首先我尝试一个简单的选择。
但是选择仍然是空白。
你能给我一些暗示吗?这是我的页面:
<html><head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="jquery.jcombo.js"></script>
</head>
<body>
<select name="list1" id="list1"></select><br />
<!--<select name="list2" id="list2"></select><br />
<select name="list3" id="list3"></select>-->
<script type="text/javascript">
$( document ).ready(function() {
{
$("#list1").jCombo("getBuilding.php", { selected_value : '1' } );
//$("#list2").jCombo("getStates.php?id_country=", { parent: "#list1" });
// $("#list3").jCombo("getCities.php?id_state=", { parent: "#list2" });
});</script>
</body></html>
我的getBuilding.php是:
<?php
require_once 'dbconnection.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!db_server) die("Unable to connection_aborted to MySQL: " . mysql_error());
mysql_select_db($db_database) or die ("Unable to connection_aborted to MySQL: " . mysql_error());
// Esegui query nel giusto ordine
//(value,text)
$query = "SELECT * FROM Building";
$result = mysql_query($query);
$items = array();
if($result && mysql_num_rows($result)>0) {
while($row = mysql_fetch_array($result)) {
$option = array("id" => $row[0], "value" => htmlentities($row[1]));
$items[] = $option;
}
}
mysql_close();
$data = json_encode($items);
// convertire in formato JSON e stampare
$response = isset($_GET['callback'])?$_GET['callback']."(".$data.")":$data;
echo($response);
?>
此页面有效。我获得了正确格式的数据。
[{ “ID”: “1”, “值”: “号楼”},{ “ID”: “2”, “值”: “Building2”},{ “ID”: “4”,”值 “:” Building3 “},{” ID “:” 5" , “值”: “Building4”}] 但它没有出现在选择中。
由于
答案 0 :(得分:0)
问题是firefox与jcombo不兼容..它适用于chrome的浏览器!