954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem With Getting Checkbox Value

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!

SUGARRUSH
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

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.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: