Welcome Guest, Not a member yet? Register   Sign In
Can someone help about form_dropdown() and onChange() in CodeIgniter
#1

[eluser]Unknown[/eluser]
Hi everybody!! I a newbie for CodeIgniter. I would like to ask all you guys.

I have to table in databases, tb_customer and tb_customer_site. Firstly, I query customer name to show in first drop-down list (as below code). I want to do that once I select customer name, system should query site name for that customer and show in the second drop-down list without refresh page. I understand that I can use onChange() in 4th parameter of form_dropdown(). I already test by alerting some text but It dose not work.

##My controller
Code:
//Query CUS_CODE and CUS_NAME from TB_CUSTOMER
  $query = $this->db->get('tb_customer');
  $result = array();
  
  //Assign query result to dropdown list
   $result['0'] = '- - - Select One - - -';
   foreach($query->result_array() as $row):
    $result[$row['CUS_CODE']] = $row['CUS_NAME'];
   endforeach;
  $data['listCusName'] =  $result ;
  
  //Send all parameters to view section
  $this->load->view('mrtg_frm',$data);

##My view
Code:
<?
  $js = 'onChange="alert("Hello World");"';
  echo form_dropdown('mrtgCusName', $listCusName, '0', $js);  
  ?>

Thank you your kind. ^^


Messages In This Thread
Can someone help about form_dropdown() and onChange() in CodeIgniter - by El Forum - 11-19-2012, 03:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB