[eluser]Unknown[/eluser]
i have browse and got reference about edit form
the another field data will auto fill if i choose data from combobox name
the problem is i want to change the combo box with input form like other, but if change
<select id="formSelect" name="name" class="input-block-level">
<? foreach($contacts as $contact): ?>
<option value="<?=$contact['name']; ?>"><?=$contact['name']; ?></option>
<? endforeach; ?>
</select>
with
<input type="text" name="name" class="input-block-level" placeholder="name" >"
it will not auto fill another field
please help me with that
below some capture code from my view and controll
view code
Code:
<form id="formEdit" class="well" accept-charset="utf-8">
<select id="formSelect" name="name" class="input-block-level">
<? foreach($contacts as $contact): ?>
<option value="<?=$contact['name']; ?>"><?=$contact['name']; ?></option>
<? endforeach; ?>
</select>
<input type="email" name="email" class="input-block-level" placeholder="Email" required maxlength="40" value="<?=$firstcontact['email']?>">
<input type="text" name="phone" class="input-block-level" placeholder="Phone" required maxlength="15" value="<?=$firstcontact['phone']?>">
<button type="submit" class="btn btn-warning btn-large">
<i class="icon-pencil icon-white"></i> Edit Contact</button>
controller code
Code:
public function edit()
{
$contacts = $this->contact_model->get_names($this->session->userdata('uid'));
if (count($contacts) > 0) {
$firstcontact = $this->contact_model->get_data(
$this->session->userdata('uid'), $contacts[0]['name']);
} else {
$firstcontact = array('email' => '', 'phone' => '');
}
$this->load->view('edit', array(
'contacts' => $contacts,
'firstcontact' => $firstcontact
));
}
public function edit_contact()
{
sleep(1);
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required|max_length[40]|callback_alpha_dash_space');
$this->form_validation->set_rules('email', 'Email', 'required|max_length[40]|valid_email');
$this->form_validation->set_rules('phone', 'Phone', 'required|max_length[15]|alpha_numeric');
if ($this->form_validation->run() == FALSE) {
$message = "<strong>Editing</strong> failed!";
$this->json_response(FALSE, $message);
} else {
$this->contact_model->update($this->input->post('name'), $this->input->post('email'),
$this->input->post('phone'), $this->session->userdata('uid'));
$message = "<strong>".$this->input->post('name')."</strong> has been edited!";
$this->json_response(TRUE, $message);
}