douhuxi4145 2014-04-09 15:08
浏览 10

基于点击按钮更新表格时的案例陈述?

I've got a table like below:

<tr>
            <td>{{ item.wo_num_and_date }}</td>
            <td>{{ item.comp_name_and_number }}</td>
            <td>{{ item.finish_sizes }}</td>
            <td>{{ item.material }}</td>
            <td>{{ item.total_num_pieces }}</td>
            <td>{{ item.workorder_num_one }}</td>
            <td>{{ item.notes_one }}</td>
            <td id='signoff_userone'><input type='button' id='signoff_user_one' data-rowid={{ item.id }} value='Signoff' /> {% if item.signoff_user_one is defined and item.signoff_date_one is defined %}{{ item.signoff_user_one.name|title }} {{ item.signoff_date_one }} {% endif %}</td>
            <td>{{ item.workorder_num_two }}</td>
            <td>{{ item.notes_two }}</td>
            <td id='signoff_usertwo'><input type='button' id='signoff_user_two' data-rowid={{ item.id }} value='Signoff' /> {% if item.signoff_user_two is defined and item.signoff_date_two is defined %}{{ item.signoff_user_two.name|title }} {{ item.signoff_date_two }} {% endif %}</td>
            <td>{{ item.workorder_num_three }}</td>
            <td>{{ item.notes_three }}</td>
            <td><input type='button' id='signoff_user_three' value='Signoff' /> {{ item.signoff_user_three.firstname }} {{ item.signoff_user_three.lastname }}</td>
        </tr>

Fiddle: http://jsfiddle.net/qwUV4/1/

Here's my php code I call when a button is clicked, everything works well for the first "Sign Off" box but the other 2 don't work, obviously because of my Update statement below which is only set to update column "signoff_user_one".

<?php
    require_once('../includes/config.php');

    $user_id = getuserinfo($loggedin_id);
    $row_id = (int)mysqli_escape_string($dbc3, $_POST['rowid']);


    $sql = "UPDATE checklist_component_stock SET signoff_user_one = $loggedin_id, signoff_date_one = NOW() WHERE id = " . $row_id;
    mysqli_query($dbc3, $sql);


    $ret = array('rowid' => $row_id, 'user' => $user_id, 'date' => date('Y-m-d H:i:s')); //date('M d, Y')
    echo json_encode($ret);
?>

My question is, would I need cases so the script checks whether its signoff_user_one, user_two, or user_three and executes the correct update statement? How would I do something like that? Is there another solution?

  • 写回答

1条回答 默认 最新

  • dqxboe2628 2014-04-09 15:18
    关注

    Are you using a loop? Because in such a case, it would probably not work very well.It should work well with the buttons and the specific ids which you have captured.You could use an isset function and use the name attribute for the button..

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line