Ich versuche, eine Eingabe Drop-Down-Beispiel zu ändern, um Werte zu verwenden, die ich aus einer db ziehen. Hier ist mein Code.DropDown Eingabe mit Werten aus PHP json und implementiert mit JQuery
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
var dropoffsuburbcode2 = [];
getEBRates();
function getEBRates()
{
if (window.XMLHttpRequest) {xmlhttp3 = new XMLHttpRequest();}
else {xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp3.onreadystatechange = function()
{
if (xmlhttp3.readyState == 4 && xmlhttp3.status == 200)
{
dropoffsuburbcode = xmlhttp3.responseText;
setcode(dropoffsuburbcode);
}
};
xmlhttp3.open("GET","php/Rates.php",true);
xmlhttp3.send();
}
function setcode(suburb){
dropoffsuburbcode2 = suburb;
dropoffsuburbcode2 = dropoffsuburbcode2.replace(/['"\]\[]/g, '');
alert(dropoffsuburbcode2);
Diese Warnung kehrt POCODE1SUBURB1, POCODE1SUBURB2
Dieser Code funktioniert nur mit availableTags, aber wenn ich versuche, wie zu verwenden dropoffsuburbcode2 i unten tun, ich habe nichts bekommen.
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL" ];
$("#tags").autocomplete({
source: dropoffsuburbcode2
});
};
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
PHP-Datei Code (Rates.php)
$strSQL2 = "SELECT * FROM db_ebrates";
$EventList_rs2 = mysql_query($strSQL2);
while($row = mysql_fetch_array($EventList_rs2)) {
$ebsuburbarrray[] = "".$row['ebratesPostcode']. "" .$row['ebratesSuburb']. "";
}
echo json_encode($ebsuburbarrray);
Vielen Dank für jede Hilfe