我有一个表单和一些jQuery,它通过AJAX生成并显示一个下拉列表,跟随另一个下拉列表的结果,这可以正常使用下面的代码:
下拉列表的html占位符:
<select name="client2" id="client2">
<option value="0">Client2 Account..</option>
</select>
调用此SQL查询时:
public function ShowClient2() {
$sql = "SELECT * from table ";
$res = mysql_query($sql,$this->conn);
$client2 = '<option value="0">Client Account...</option>';
while($row = mysql_fetch_array($res)) {
$client2 .= '<option value="' . $row['accounts_client_id'] . '">' . $row['client'] . '</option>';
}
return $client2;
}
我的问题
我不想要一个选择框/下拉列表我想要复选框。
我在我的代码中尝试将其作为替换行:
while($row = mysql_fetch_array($res)) {
$client2 .= '<input id="cat4" type="checkbox" name="' . $row['client'] . '" value="' . $row['accounts_client_id'] . '" />';
}
确定没有实际的jquery:我不认为jQuery是问题,因为它作为一个选择框而不是一个复选框:
这是调用它的jQuery
$(document).ready(function(){
$("select#tote").change(function(){
$("select#client2").attr("disabled","disabled");
$("select#client2").html("<option>wait...</option>");
var id = $("select#tote option:selected").attr('value');
$.post("ajax/report_run/select_type2.php", {id:id}, function(data){
$("select#client2").removeAttr("disabled");
$("select#client2").html(data);
});
});
});
当我的第一个下拉列表发生变化时,这会运行。它会将ShowClient2
带回我的占位符。