1
私は、動的ドロップダウンを持つプロジェクトで働いています。第2のデータは最初のデータに依存しますが、問題はあります。 3つのファイル(index.htmlを、getcountry.php.script.js)HTMLの動的ドロップダウンエラー
index.htmlをコード
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<select id="slctmake"></select></br>
<select id="slctmodel"></select>
<script src="jquery-1.10.2.js"></script>
<script src="script.js"></script>
</body>
</html>
getcountry.phpコード
<?php
include "connect.php";
$query="SELECT DISTINCT country FROM `widgets` where country !='' ";
$data=mysqli_query($conn,$query);
$makes = array();
while($row=mysqli_fetch_array($data)){
array_push($makes,$row["country"]);
}
echo json_encode($makes);
?>
script.jsコードからプロジェクトコンテンツ
$(document).ready(function() {
$.getJSON("getcountry.php", success =function(data)
{
var options = "";
for (i=0 ; i < data.length ; i++){
options +="<option value '".data[i].tolowercase()+"'>"+data[i]+"'</option>";
}
$("#slctmake").append(options);
});
});
だから私の問題で誰も助けてくれない選択を選択したコードは、私はあなたのJSコードで
アヤックスがデータを取得している場合、私はこのエラーを修正して、まだデータがない、あなたはより多くの私を助けることができる、してください –
チェック – Bak
申し訳ありませんIAMまだ理由初心者は、あなたが私まで私に確認してくださいこれを確認する方法 –