开发者

Pass tick boxes through basket process

开发者 https://www.devze.com 2023-04-11 10:38 出处:网络
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'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 f开发者_StackOverfloworm 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.


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.


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)
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号