doubiao9775 2013-03-26 09:55
浏览 49
已采纳

如何在链接其他值时勾选复选框

I can't seem to properly work through this list I have. I have x tables with number of rows between 10 and 200. Each row represents an item, and if you select one or more checkboxes, it loops through those and updates/adds/deletes rows where needed. How would I go about doing this?

I currently have a hidden field with id[], and two checkboxes with own[] and special[]. The ID is obviously the unique item ID, and the two checkboxes represent whether you own a normal version or a special version (or none, or both). When I loop through them, all IDs are echoed but I can't seem to connect the values of the two checkboxes to them. A simple for loop won't work, because all IDs are echoed, and therefore the checkboxes are not properly looped through.

I'm somewhat knowledgeable about PHP, so hit me with what you've got!

  • 写回答

2条回答 默认 最新

  • douping7105 2013-03-26 10:06
    关注

    You should try to make bidimensional arrays (if I understood well). You can also forget the hidden field :

    checkboxes[<?= $id ?>][own] and checkboxes[<?= $id ?>][special]. You shall have such an array in php :

    $_POST['checkboxes'] => array(
                             1 => array(
                                  'own' => 'on'
                             ),
                             3 => array(
                                  'own' => 'on',
                                  'special' => 'on
                             )
                        );
    

    Here you have checked "own" checkbox for id "1" and "own" and "special" checkboxes for id "3".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

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