Welcome Guest, Not a member yet? Register   Sign In
Dynamic input field saving
#1

Newbie yet & this is the first time i'm working with dynamic fields, please check this video first.

http://www.screencast.com/t/Tl8jWxztdfG6


As i demonstrated i have this input field in my form (view).

Code:
<input type="text" name="fault[0]" placeholder="" class="form-control name_list" />  

<button type="button" name="add" id="add_fault_fld" class="btn btn-success">Add More</button>

what i need to know is, how can i store the values of these generating fields in database. there are other fields in this form as well i have already know & saving the results to the database using below model.

Model

PHP Code:
public function new_jobsheet_save() {

 $new_job_insert_db = array(

 'cus_name'=> $this->input->post('cusname'),
 'vehicle_number'=> $this->input->post('vehicles'),
 'date_in'=> $this->input->post('datein'),
 'date_out'=> $this->input->post('dateout'),
 'expected_completion'=> $this->input->post('datecom'),
 'mileage_in'=> $this->input->post('mileagein'),
 'mileage_out'=> $this->input->post('mileageout'),
 'service_advisor'=> $this->input->post('serviceadvisor'),
 
);

$insert $this->db->insert(' jobsheets'$new_job_insert_db);
    
 return $insert
;



  
in the model at the moment i'm not saving the data of joblist as you can see, because if i do so it only save default fields value but no others.

my table is "jobsheets"  on this table i have field called "faults_reported_by_customer" and this is where i need the data from my dynamic input fields needs to store. how can i achive this prefer some coding level guidance as i am clueless.

also is it possible to store is result in separate row of database? i really appreciate your help on this.
Reply
#2

Your missing the value field for one.

Code:
<input type="text" name="fault[0]" placeholder="" class="form-control name_list" value="" />  

<button type="button" name="add" id="add_fault_fld" class="btn btn-success">Add More</button>
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(08-09-2016, 05:25 AM)InsiteFX Wrote: Your missing the value field for one.

Code:
<input type="text" name="fault[0]" placeholder="" class="form-control name_list" value="" />  

<button type="button" name="add" id="add_fault_fld" class="btn btn-success">Add More</button>

I am sorry what do you mean friend?
Reply
#4

PHP Code:
<input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" /> 

Use the form_helper to set the value field.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB