我希望在文本字段中输入值(会员编号)时,它会检查数据库中的相应名称并显示在 div 上......这就是我到目前为止所做的......
我的jQuery代码
$(function(){
var dis=$('#full');
$('#membership_number').change(function(e){
var sel=$(this).val();
dis.html('');
if(sel!='0'){
$.get('get_leader.php',{sel:sel},function(data){
dis.html(data);
});
}
}).change();
});
我的PHP代码
if(isset($_GET['sel'])){
$membership_num=$_GET['sel'];
if(!empty($dregion)){
$search=mysql_query("SELECT fname,mname,lname from members where
membership_number='$membership_num'")
or die("Error occured in selecting a table");
while($rows=mysql_fetch_array($search)){
$fname=ucfirst($rows['fname']);
$lname=ucfirst($rows['lname']);
$mname=ucfirst(substr($rows['mname'],0,1));
$full=$fname.'.'.$mname.'.'.$lname;
echo $full;
}
}
}
我的html代码
<div class="control-group">
<label class="control-label" for="id_password">Membership Number</label>
<div class="controls">
<input name="membership_number" maxlength="100"
placeholder="Enter membership Number ..." type="text"
class="input-large" id="membership_number" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="id_password">Full Name</label>
<div class="controls" id='full'>
//display data here...
</div>
</div>