|
/code><code class="php plain" style="margin:0px!important; padding:0px!important; background:none!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas," bitstream vera sans mono new min-height:auto>>
<code class="php plain" style="margin:0px!important; padding:0px!important; background:none!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas," bitstream vera sans mono new min-height:auto>>
<meta http-equiv="</code">
<code class="php string" style="margin:0px!important; padding:0px!important; background:none!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas," bitstream vera sans mono new min-height:auto color:blue>"Content-Type" content="text/html;
charset=utf-8" />
<title>无标题文档</title>
<script src="</code"><code class="php string" style="margin:0px!important; padding:0px!important; background:none!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace!important; min-height:auto!important; color:blue!important">"../jquery-3.2.0.min.js"</script>>
<h1>用户角色对应</h1>
<p></p>
<select id="</code"><code class="php string" style="margin:0px!important; padding:0px!important; background:none!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas," bitstream vera sans mono new min-height:auto color:blue>"user">
<?php
require"../DBDA.class.php";
$db = new DBDA();
$sql = "select
* from users";
$arr = $db->query($sql,1);
foreach($arr as $v)
{
echo"<option value="'{$v[0]}'">{$v[2]}</option>";
}
?>
<br>
<p>请选择角色:</p>
<?php
$sql = "select
* from juese";
$arr = $db->query($sql,1);
foreach($arr as $v)
{
echo "<input type="'checkbox'" class="'ck'" value="'{$v[0]}'/">{$v[1]}";
}
?>
<br>
<input type="</code"><code class="php string" style="margin:0px!important; padding:0px!important; background:none!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas," bitstream vera sans mono new min-height:auto color:blue>"button" value="保存" id="baocun" />
<script type="</code"><code class="php string" style="margin:0px!important; padding:0px!important; background:none!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace!important; min-height:auto!important; color:blue!important">"text/javascript"</script>>
Xuan();
$("#user").change(function(){
Xuan();
})
$("#baocun").click(function(){
var uid
= $("#user").val();
var str
= "";
var ck
= $(".ck");
for(var i=0;i<ck.length></ck.length>
{
if(ck.eq(i).prop("checked"))
{
str
= str + ck.eq(i).val()+",";
}
}
str
= str.substr(0,str.length-1);
$.ajax({
url:"add.php",
data:{uid:uid,js:str},
type:"POST",
dataType:"TEXT",
success: function(data){
alert("保存成功!");
}
})
})
function Xuan()
{
var uid
= $("#user").val();
$.ajax({
url:"chuli.php",
data:{uid:uid},
type:"POST",
dataType:"TEXT",
success: function(data){
var js
= data.trim().split("|");
var ck
= $(".ck");
ck.prop("checked",false);
for(var i=0;i<ck.length></ck.length>
{
var v
= ck.eq(i).val();
if(js.indexOf(v)>=0)
{
ck.eq(i).prop("checked",true);
}
}
}
})
}
|