<script type="text/javascript">
function bindCity() {
// Some javascript code
//declare options array and populate
var modelnames = new Array();
$.get("file.php?mt=" + qs, function(data) {
eval(data);
if(modelnames.length > 0) {
addOptions(modelnames);
}
}
);
}
function addOptions(cl) {
//enable child select and clear current child options
$("#mn").removeAttr("disabled");
$("#mn").html('');
//repopulate child list with array from helper page
var city = document.getElementById('mn');
for(var i = 0; i < cl.length; i++) {
city.options[i] = new Option(cl[i].text, cl[i].value);
}
}
</script>
这是PHP脚本(获取值为$ mt后): -
$SQLqueryTry = "SELECT mn FROM pd WHERE pd_mt = '$mt'";
$SQLqueryETry = mysql_query($SQLqueryTry, $dacreint) or die(mysql_error());
while ($Try = mysql_fetch_array($SQLqueryETry))
{
$output = "modelnames.push(new Option('$Try[mn]', '$Try[mn]'));\n";
}
我在PHP文件中的输出代码: -
header('Content-type: text/plain');
echo $output;
现在我只能在$output = "modelnames.push(new Option('$Try[mn]', '$Try[mn]'));\n";
但是当我向.
添加$output =
时,要$output .= "modelnames.push(new Option('$Try[mn]', '$Try[mn]'));\n";
我无法获得任何价值。有什么问题?
答案 0 :(得分:0)
您是否能够在错误日志中看到任何错误?
我的第一个猜测是,您在使用$output
之前忘记初始化.=
变量。
也许试试:
$output = "";
while ($Try = mysql_fetch_array($SQLqueryETry))
{
$output .= "modelnames.push(new Option('$Try[mn]', '$Try[mn]'));\n";
}