我是网络开发的新手。在我的数据库中,我有一个名为customers的表。有两列名为客户名称和客户地址。在我的界面中,我有一个可以搜索客户的字段。在界面中,还有另一个名为“客户地址”的字段。我的目的是在选择客户名称后立即填写现场客户地址。
<tr>
<th valign="top" style="text-align:right">Customer Name: </th>
<td><input type='text' id="customer_name" class="text_box" autocomplete="off" name='customer_name' value="<?= set_value('customer_name', $customer_name) ?>" /><?= form_error('customer_name', '<span class="error">', '</span>') ?>
<div class="jcustomer_list"></div>
<input name="customer_id" value="" type="hidden" class="customer_id">
</td>
</tr>
<tr>
<th valign="top" style="text-align:right">Customer Address: </th>
<td><input type='text' id="customer_adress" class="text_box" autocomplete="off" name='customer_adress' value="<?= $_REQUEST['customer_adress'] ?>" /><?= form_error('customer_adress', '<span class="error">', '</span>') ?>
<div class="jcustomer_list"></div>
<input name="customer_id" value="" type="hidden" class="customer_id">
</td>
</tr>
bind:function(){
$j('.jcustomer_list').find('li').unbind('click');
$j('.jcustomer_list').find('li').bind('click',function(){
$j('#customer_name').val($j(this).attr('title'));
//$j('#customer_address').val($j(this).attr('title'));
$j('.customer_id').val($j(this).attr('rel'));
var cid=$j(this).attr('rel');
customer.getPreviousBalance(cid);
customer.getCustmerAddress(cid);
$j('.jcustomer_list').css('display','none');
});
},
getCustmerAddress:function(cid){
$j.ajax({
type:'post',
url:base_url+'ajax/load_customer_address',
data:{
cid:cid
},
//here a success function must be added but I am not being able to this.
error:function(a,b,c){
},
});
}
}
public static function get_customer_address($cid) {
$CI = &get_instance();
$c = sql::row("customers", "customer_id='$cid'", "customer_address");
return $c;
}
答案 0 :(得分:0)
您的脚本看起来已添加了额外的} 括号和&amp;这里应该是AJAX代码。 我假设你的控制器函数返回正确的结果。
FormData