Hey guys. I've been searching and searching but none of the information I get makes any sense. I have a simple problem. On my checkout page, I allow my customers to select a charity to donate to. I can't however figure out how to get the information from which checkbox they selected. There are three checkboxes. Here is the code I am using.

<h2 id="checkoutConfirmDefaultHeadingComments"><?php echo HEADING_CHARITY_DONATION; ?></h2>
<div class="buttonRow forward"><?php echo  '<a href="' . zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_EDIT_SMALL, BUTTON_EDIT_SMALL_ALT) . '</a>'; ?></div>
<div><?php echo (empty($order->info['comments']) ? NO_COMMENTS_TEXT : nl2br(zen_output_string_protected($order->info['comments'])) . zen_draw_hidden_field('comments', $order->info['comments'])); ?></div>
<br class="clearBoth" />
<?php
//  }
?>
<hr />

Now I know that a LOT of that is wrong. I copied and pasted another part of the code to built the outside and appearance, but when I get to the part of having to get the information from the checkbox, I am lost.

The part of the code where they select the checkbox is

<?php echo  zen_draw_checkbox_field('conditions', '1', false, 'id="conditions"');?>
<label class="checkboxLabel" for="conditions"><?php echo TAXT_CONDITIONS_CONFIRMS1; ?></label></br>
<?php echo  zen_draw_checkbox_field('conditions', '1', false, 'id="conditions"');?>
<label class="checkboxLabel" for="conditions"><?php echo TAXT_CONDITIONS_CONFIRMS2; ?></label></br>
<?php echo  zen_draw_checkbox_field('conditions', '1', false, 'id="conditions"');?>
<label class="checkboxLabel" for="conditions"><?php echo TAXT_CONDITIONS_CONFIRMS3; ?></label>

I know it has weird labels. I made them that way to be distinct yet simple. But yea. Can anyone help me with this? Thanks!

Member Avatar for diafol

It seems that you're using the same id for each checkbox - you're not allowed to do that. name attribute yes, but not id. CHange the id for each checkbox to be unique. Your 'for' attribute in the label should be the same as the checkbox id - if not, the checkbox won't be toggled when you click the label - or worse still the wrong checkbox will be toggled.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.