douzhan1031 2015-07-01 10:04
浏览 42

如何使用动态复选框?

I am using code igniter. For employee i need to select possible services they can perform.i have a field service limitation where i need to store many service id that the employee can perform. my view file where i have service list is

<div class="container top">

      <ul class="breadcrumb">
         <li>
          <a href="http://localhost/elfanto/elfanto_billing/admin/employee">
            Admin          </a> 
          <span class="divider">/</span>
        </li>
        <li class="active">
          Service        </li>
      </ul>


     <div class="row">
        <div class="span12 columns">
          <div >

            <?php

            $attributes = array('class' => 'form-inline reset-margin', 'id' => 'myform');

            $options_manufacture = array(0 => "all");
            foreach ($category as $row)
            {
              $options_manufacture[$row['id']] = $row['name'];
            }
            //save the columns names in a array that we will use as filter         
            $options_products = array();    
            foreach ($service as $array) {
              foreach ($array as $key => $value) {
                $options_products[$key] = $key;
              }
              break;
            }
 echo form_open('admin/employee', $attributes);

            ?>

          </div>

          <table class="table table-striped table-bordered table-condensed">
            <thead>
              <tr>
                <th class="header">Service id</th>
                <th class="yellow header headerSortDown">Service name </th>
                <th class="green header">Service catogary</th>
                <th class="red header">Service tax</th>
                <th class="red header">Service length</th>
                <th class="red header">Service price</th>
                <th class="red header">Actions</th>
              </tr>
            </thead>
            <tbody>
              <?php
              foreach($service as $row)
              {
                echo '<tr>';
                echo '<td>'.$row['id'].'</td>';
                echo '<td>'.$row['service_name'].'</td>';
                echo '<td>'.$row['category'].'</td>';
                echo '<td>'.$row['service_tax'].'</td>';
                echo '<td>'.$row['service_length'].'</td>';
                echo '<td>'.$row['service_price'].'</td>';
                echo '<td class="crud-actions">
                 <input type="checkbox" value=""/>

                </td>';
                echo '</tr>';
              }
              ?>      
            </tbody>
          </table>

          <?php echo '<div class="pagination">'.$this->pagination->create_links().'</div>'; ?>

      </div>
    </div>
    <div>
    <button class="btn btn-primary" type="submit">Save changes</button>
            <button class="btn" type="reset">Cancel</button>
    </div>
      <?php echo form_close(); ?>

here i have multiple check boxes when i choose the check box i need to get the id value and update the employee service limitation field with 4 or more id

  • 写回答

1条回答 默认 最新

  • drwiupraq047311240 2015-07-01 10:16
    关注

    You can use input arrays -

    <input type="checkbox" value="'.$row['id'].'" name="services[]"/>
    

    And store it in database as json string.

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程