javascript - Cascading Select with jCombo -
i want create triple nested select first of try simple select.
but select remain blank.
can gime me hint?
this page:
<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>
where getbuilding.php is:
<?php require_once 'dbconnection.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!db_server) die("unable connection_aborted mysql: " . mysql_error()); mysql_select_db($db_database) or die ("unable connection_aborted mysql: " . mysql_error()); // esegui query nel giusto ordine //(value,text) $query = "select * 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); ?>
this page works. obtain data formatted correctly.
[{"id":"1","value":"building1"},{"id":"2","value":"building2"},{"id":"4","value":"building3"},{"id":"5","value":"building4"}] not appear in select.
thanks
the problem firefox not compatible jcombo.. works explorer of chrome!
Comments
Post a Comment