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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?