javascript - CodeIgniter - Create dynamic html table using form helper functions? -


i've dynamic table adds more rows. here table.

<table>    <thead>     <tr class="success">      <th>bank/lender</th>      <th>add more</th>     </tr>   </thead>   <tbody >    <tr>     <td>      <?php        $data = array(               'name' => 'debt_info_bank_name[]',               'id' => '',               'class' => 'form-control',               'placeholder' => 'bank/lender name'               );        echo form_input($data);       ?>     </td>     <td>      <input class="add btn btn-success btn-sm" type="button" value="add more"  />     </td>   </tr> </tbody> 

and here javascript part:

    $(document).on('click','.add',function(){      $(this).val('delete');     $(this).attr('class','del btn btn-danger btn-sm');     var appendtxt = '<tr><td><?php  $data = array(                                     'name' => 'debt_info_bank_name[]',                                     'id' => '',                                     'class' => 'form-control',                                     'placeholder' => 'bank / lender name'                                   );                                   echo json_encode(form_input($data)); ?></td><td><input class="add btn btn-success btn-sm" type="button" value="add more"  /></td></tr>';     $("#dyn_table > tbody > tr:last").after(appendtxt);     });      $(document).on('click','.del',function(){          $(this).parent().parent().remove();      }); 

it adds rows quotes"" in each td element. how can correct it?

note: if add fields in javascript code using html elements like

 var appendtxt = '<tr><td><input type="text" placeholder="bank/lender name"  /></td> <td><input class="add btn btn-success btn-sm" type="button" value="add more" /></td></tr>'; 

then goes fine want add fields in codeigniter style because more safe that.

remove json_encode here. echo

 echo form_input($data); ?></td><td><input class="add btn btn-success btn-sm" type="button" value="add more"  /></td></tr>'; 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -