jQuery.post输出下拉列表

时间:2012-05-12 11:51:50

标签: php javascript jquery

我创建了一个下拉列表,它在单独的页面中运行良好: normal

但是,当我使用jQuery.post()将其输出到PP页面的表格中时,内容会从下拉列表中用完: abnormal

我正在使用我们的jQuery:

<script>
function showestate(){
$.post('admin/page/ur/showestate.php',{ 
zid: document.getElementById('zone').value

},
function(output){
$('#showestate').html(output);
}); 
}
showestate();
</script>

<div id='showestate'>
    </div>

请帮忙!谢谢!

下拉列表如下:

<?php
include "../../db.php";
session_start();

?>
<select name="estate" id="estate" />
<?php
$sql_sel_estate = "select * from [estate]";
$result_sel_estate = mssql_query($sql_sel_estate, $conn);
while ($record_sel_estate = mssql_fetch_array($result_sel_estate))
{
$estateid = $record_sel_estate['estateid'];
$estatename = $record_sel_estate['estatename'];
$estatenameen = $record_sel_estate['estatenameen'];
$estatezoneid = $record_sel_estate['estatezoneid'];
$estatecode = $record_sel_estate['estatecode'];

?>

<option value="<?=$estateid?>">
<?=$estatenameen?><br>
</option>
<?php
}
?>
</select>

1 个答案:

答案 0 :(得分:1)

您必须检查/提醒output

中的内容

它应该包含

<option>option 1</option>
<option>option 2</option>
<option>option 3</option>

即。只有选项。没有其他的HTML。没别了。

还会创建一个ID为<select>的{​​{1}}元素。你可以给div任何其他id 当您将html添加到showestate