如何使用 JavaScript 和 PHP 在办公自动化编程中选择人员



我想要实现的是我选择了复选框部门,并且该部门的员工将显示在第二div.so 我可以选择员工,并在选定的员工div中显示自动.我可以将评论传输到这些选定的 people.it 通常出现在办公自动化中。但是如何使用javascript解决这个问题? 我当前的代码是: $sql ="从hpc_empolyee中选择用户名;";

我的修改.php

if(isset($_POST['get_staff']))
{
$staff=$_POST['get_staff'];
$sql = "select distinct 中文名 from hpc_用户表 where 角色='$staff';"; 
echo '<table  >';
$sel=$conn->query($sql);
while($row=$sel->fetch(PDO::FETCH_NUM))
{
echo '<tr>';
echo '<td style="word-break:break-all;"><input type="checkbox" id="staff_input" value="'.$row[0].'">'.$row[0].'</td>';
echo '</tr>';
}
echo '</table>';
}

我的网页:

<div id="staff_div" class="staff" ></div>
<div class="selected_staff" id="selected_staff" onclick="this.focus();"></div><br />

我的js:

function change_staff(id){
var data_to_fetch = $('#'+id).val();
$.ajax({
type:"POST",
url:"modify.php",
dataType:'html',
cache: false,    
data: {get_staff: data_to_fetch},
success: function(data){
$('#staff_div').html("");
$('#staff_div').html(data);
},
error: function(){
alert('failed');
}
});

我希望警报("测试"(可以工作:

$('#staff_input').click(function(e){
e.preventDefault();
alert("test");     
});     
});

最新更新