php - CI : save values from hidden fields to another table -


i created form in ci framework 60 fields, , database works. want separate fields , send table, linked primary table (with relatioship, of course). hide fields, , show if radio button checked "yes" :

<!-- other fields --> <div><label class="control-label" for="imp_status">3rd party</label>  <div class="controls">   <table>    <tr>     <td><input type="radio" name="imp_status" id="imp_status_yes" value="1" onclick="javascript:importircheck()"> yes</td>     <td><input type="radio" name="imp_status" id="imp_status_no" value="0" onclick="javascript:importircheck()"> no</td>    </tr>   </table>  </div> </div> <div style="display:none" id="info_imp">  <fieldset> somefields </fieldset> </div> <!-- other fields --> 

script :

function importircheck() {     if (document.getelementbyid('imp_status_no').checked) {         document.getelementbyid('info_imp').style.display = 'none';         $("#imp_status_no").val("");     }     else {         document.getelementbyid('info_imp').style.display = 'block';         $("#imp_status_yes").val("");         $("#imp_comp_name").val("");         ...     } } 

the view working, i'm confused how should value (especially imp_status because there 2 id) database. there's save button @ end of form , linked script. sent other values script. have table_primary (.., imp_status, id_imp,..) , table_imp (id_imp,...). when there's no 3rd party, want imp_status column save "0" & set id_imp null/0 (in table_primary). if there's 3rd party, imp_status column should save "1" & save info 3rd party (to table_imp primary key id_imp). right way (for script)? how should modify model , controller? current controller (no imp_status , id_imp yet):

... $imp_comp_name=$this->input->post("imp_comp_name"); $this->form_m->set_imp_comp_name($imp_comp_name); $imp_comp_dir=$this->input->post("imp_comp_dir"); $this->form_m->set_imp_comp_dir($imp_comp_dir); ... $result = $this->form_m->insert(); 

and current model :

// there properties & setters public function insert(){    $sql = "insert table_primary           (...,imp_comp_name,...) values (...,'".$this->imp_comp_name."',...)";    return $this->db->query($sql); } 

i hope question isn't confusing. links read , learned welcomed, thanks.

all though question little bit confusing trying give answer of it, require further assist can write me complete source code.

first of on server side , radio button value $imp_status=$this->input->post('imp_status'); , value value of selected radio button , according value of radio button, can update database , create relation between 2 table.

but in query how decide there third party in form, please elaborate more on it.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -