<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";
我无法获得任何价值。问题是什么?