Welcome Guest, Not a member yet? Register   Sign In
How to auto fill a text field?
#1

[eluser]glenconde[/eluser]
Hi guys, please help me.. i wanted to "Auto Fill my textbox" from a computation of another textbox.. but i can't get it.
anybody help please.

thank's!

this is my code in controllers

Code:
function save($item_id=-1)
{
  $item_data = array(
  'name'=>$this->input->post('name'),
  'description'=>$this->input->post('description'),
  'category'=>$this->input->post('category'),
//  'supplier_id'=>$this->input->post('supplier_id')=='' ? null:$this->input->post('supplier_id'),
  'item_number'=>$this->input->post('item_number')=='' ? null:$this->input->post('item_number'),
  'cost_price'=>$this->input->post('cost_price')*(.30)+('cost_price')=='' ?null:$this->input->post('unit_price'), [i]<---- [b]the Result of this here i want to post to unit_price textfield[/b][/i]
  'unit_price'=>$this->input->post('unit_price'),
  'quantity'=>$this->input->post('quantity'),
  'reorder_level'=>$this->input->post('reorder_level'),
  'allow_alt_description'=>$this->input->post('allow_alt_description'),
  'is_serialized'=>$this->input->post('is_serialized')
  );
#2

[eluser]glenconde[/eluser]
This is in my View file.



Code:
<div class="field_row clearfix">
&lt;?php echo form_label($this->lang->line('items_cost_price').':', 'cost_price',array('class'=>'required wide')); ?&gt;
<div class='form_field'>
&lt;?php echo form_input(array(
  'name'=>'cost_price',
  'size'=>'8',
  'id'=>'cost_price',
  'value'=>$item_info->cost_price)
);?&gt;
</div>
</div>

<div class="field_row clearfix">
&lt;?php echo form_label($this->lang->line('items_unit_price').':', 'unit_price',array('class'=>'required wide')); ?&gt;
<div class='form_field'>
&lt;?php echo form_input(array(
  'name'=>'unit_price',
  'size'=>'8',
  'id'=>'unit_price',
  'value'=>$item_info->unit_price)
);?&gt;
</div>
</div>
#3

[eluser]glenconde[/eluser]
This is in my Models

Code:
function save(&$item_data,$item_id=false)
{
  if (!$item_id or !$this->exists($item_id))
  {
   if($this->db->insert('items',$item_data))
   {
    $item_data['item_id']=$this->db->insert_id();
    return true;
   }
   return false;
  }

  $this->db->where('item_id', $item_id);
  return $this->db->update('items',$item_data);
}




Theme © iAndrew 2016 - Forum software by © MyBB