dopq87915 2011-10-06 15:54
浏览 24
已采纳

通过篮子过程传递勾选框

I'm working on a custom basket - http://www.dtrmedical.com/test-site/index.php?id=3&productid=130. I want to pass the checkbox options chosen from one form to the other.

I have two forms that represent two stages of a basket:

  1. To see the first form click the "add to wish list button". Check some options then click the "add to wish list" button at the bottom.
  2. To see the second form, click the green "wish list button". This will show the options that were chosen.

I want to show the options that were ticked in the first form, ticked on the second form. How could I do this?

Should you wish to see the code in it's entirety - http://pastebin.com/W3UVSSEx

The first form starts on line 197 and the second on line 276.

The checkboxes in both forms are displayed in this manner:

<input type="checkbox" 
       name="<? echo $productid."_".$product_quantity[id]."_".$product_option[id]; ?>" 
       value="<? echo $quote[qty]; ?>" 
/>

<input type="checkbox" 
       name="<? echo $productid."_".$product_quantity[id]."_".$product_option[id]; ?>" 
       value="<? echo $sample[qty]; ?>" 
/>

I've attempted to use isset but I'm not sure what to check against as my checkbox names are variables.

  • 写回答

2条回答 默认 最新

  • doudui5753 2011-10-06 18:31
    关注

    When you build your second form, build your checkbox the same way has you build on the first, and when you write the HTML from the loop andd checked="checked" to every checkbox who return that they are set exemple :

    This is how the name of the checkbox are defined

    $item[pid]."_".$item[qid]."_".$item[oid]

    so in the loop that generate that just check like this

    if (isset($_post[$item[pid]."_".$item[qid]."_".$item[oid]])) { 
     //Build your checkbox HTML with the checked="checked";
    } else { 
     // Build your normal checkbox (unticked)
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?