I am very new in web developing. In my database, I have the table named customers. There are two columns named customer name, and customer address. in my interface I have a field where I can search for the customers. in interface, there is another field named "customer address". My aim is to fill the field customer address no sooner had the customer name is selected.
This is my view file
<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>
This is my AJAX class
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){
},
});
}
}
This is my common helper function
public static function get_customer_address($cid) {
$CI = &get_instance();
$c = sql::row("customers", "customer_id='$cid'", "customer_address");
return $c;
}