doufen3134 2015-07-16 07:01
浏览 14

是否可以在codeigniter中使用类似操作的游标

I am creating a billing application and I am using codeigniter. I have a view where I can view the employee details.In this view file I have a action like delete and edit separately for each employee record. Is is possible to have a single edit button that can edit any employee record that is listed in my view?

My view file

<table class="resizable" bordercolor="#993300" border="1">
            <thead>
              <tr>
                <th class="header">Employee id</th>
                <th class="yellow header headerSortDown">First name</th>
                <th class="green header">Last name</th>
                <th class="red header">Email</th>
                <th class="red header">Emergency contact</th>
                <th class="red header">Category</th>
                <th class="red header">ID card</th>
                <th class="red header">Time in</th>
                <th class="red header">Time out</th>
                <th class="red header">Date of hire</th>
                <th class="red header">Date of termination</th>

                <th class="red header">Date of rehire</th>
                <th class="red header">Reference number</th>
                <th class="red header">Service limitation</th>
                <th class="red header">Chair renter</th>

                <th class="red header">Actions</th>
              </tr>
            </thead>
            <tbody>
              <?php
              foreach($employee as $row)
              {
                echo '<tr>';
                echo '<td>'.$row['id'].'</td>';
                echo '<td>'.$row['emp_first_name'].'</td>';
                echo '<td>'.$row['emp_last_name'].'</td>';
                echo '<td>'.$row['emp_email_id'].'</td>';
                echo '<td>'.$row['emp_emergency_contact'].'</td>';
                echo '<td>'.$row['category'].'</td>';
                echo '<td>'.$row['emp_id_card'].'</td>';
                echo '<td>'.$row['emp_time_in'].'</td>';
                                echo '<td>'.$row['emp_time_out'].'</td>';
                echo '<td>'.$row['emp_date_of_hire'].'</td>';
                                echo '<td>'.$row['emp_date_of_termination'].'</td>';
                echo '<td>'.$row['emp_date_of_rehire'].'</td>';
                echo '<td>'.$row['emp_reference_num'].'</td>';
                echo '<td>'.$row['emp_service_limitation'].'</td>';
                                echo '<td>'.$row['chair_renter'].'</td>';



                echo '<td class="crud-actions">
                  <a href="'.site_url("admin").'/employee/update/'.$row['id'].'" class="btn btn-info">view & edit</a>  
                  <a href="'.site_url("admin").'/employee/delete/'.$row['id'].'" class="btn btn-danger">delete</a>
                </td>';
                echo '</tr>';
              }
              ?>      
            </tbody>
          </table>

Here i have a <a> to perform edit and delete option. This action passes the id that i choose to edit or delete. Instead of having separate buttons for each employee.I need to have a single button and allow the user to select employee.Like this imageenter image description here

  • 写回答

1条回答 默认 最新

  • douxi2011 2015-07-16 08:05
    关注

    The easiest solution would be to use JQuery to attach a selected class to the row which is clicked via something like:

    $('tr').on('click', function () {
        // Remove selection from other rows
        $('tr.selected').removeClass('selected');
        // Add selection to current row
        $(this).addClass('selected');
    });
    

    That will allow you to place a 'cursor' onto a row, you'll want to style the rows with the selected class using CSS or something similar.

    Now you can have a single Edit button and use something like the following code to handle the click event:

    $('#edit').on('click', function () {
        if ($('tr.selected').length() == 0) {
            alert('Must select a row!');
        } else {
            // Handle 'edit' event by passing $(this) to whatever you need
            // $(this) will be the currently selected row
        }
    });
    

    This works since the $(this) object acts as a reference to the currently selected row.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?