通过篮子流程传递勾选框
我正在制作自定义购物篮 - http:// www.dtrmedical.com/test-site/index.php?id=3&productid=130。我想将从一种形式选择的复选框选项传递到另一种形式。
我有两个表格,代表购物篮的两个阶段:
- 要查看第一个表格,请单击“添加到愿望清单按钮”。检查一些选项,然后单击底部的“添加到愿望清单”按钮。
- 要查看第二个表格,请单击绿色的“愿望清单按钮”。这将显示所选的选项。
我想显示在第一个表单中勾选的选项,在第二个表单中勾选的选项。我该怎么做?
如果您希望查看完整的代码 - http://pastebin.com/ W3UVSSEx
第一个表单从第 197 行开始,第二个表单从第 276 行开始。
两种表单中的复选框都以这种方式显示:
<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]; ?>"
/>
我尝试使用 isset
但我没有确定要检查的内容,因为我的复选框名称是变量。
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:
- 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.
- 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在第二个表单上所需要做的就是通过以下方式访问 POST 变量:
isset($_post['My_Checkbox_Name'])
并在第二页上根据需要重新设置复选框。
All you need to do on the second form is access the POST variables via:
isset($_post['My_Checkbox_Name'])
and re-set the checkboxes as appropriate on the second page.
当您构建第二个表单时,以与构建第一个表单相同的方式构建您的复选框,并且当您从循环中编写 HTML 并将checked =“checked”到每个返回设置的复选框时,例如:
这就是复选框的名称定义为
$item[pid]."_".$item[qid]."_".$item[oid]
因此在生成该复选框的循环中只需像这样检查
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