Solved

Radio Button Checked Value

Posted on 2014-11-13
5
268 Views
Last Modified: 2014-11-17
Hello,
I'm using OpenCart 1.5.5.1 and an extension for one page checkout. I placed a 'login block' on top of the Shopping Cart form and it's elements are still linked to the extension.
Everything Works! except... the 'register' - 'guest checkout' radio buttons won't stay checked after submission. The content of the form refreshes as designed but neither of the radio buttons will stay checked.
Here's the code snippet for the radio buttons:
<p><?php echo $text_checkout; ?></p>  
  <?php $i = 0; ?>
    <?php if ($i == 0 && !$customer_logged && $simple_customer_action_register == Simple::REGISTER_USER_CHOICE) { ?>
                <tr>
                    <td class="simplecheckout-customer-left">                       
                    </td>                    
<td class="simplecheckout-customer-right">
                      <label><input type="radio" name="register" value="1"<?php echo $register == 1 ? 'checked="checked"' : '' ; ?>reload="customer_register" /><b><?php echo $text_yes ?></b>&nbsp;<b><?php echo $text_register; ?></b>&nbsp;</label></br>
                      <p><?php echo $text_register_account; ?></p>
                     <label><input type="radio" name="register" value="0"<?php echo $register == 0 ? 'checked="checked"' : '' ; ?>reload="customer_not_register" /><b><?php echo $text_no ?>&nbsp;<?php echo $text_guest; ?></b></label>                    
                     
                    </td> 
                    </tr> 
               <?php $user_choice = true; ?>
            <?php $i++ ?>     

Open in new window


Any code I place within the <label></label> tags stops the reload function.
I'm attaching two files, one is the checkout template (where my new login block is) and one is the customer template which is called by the checkout template.
Thanks in advance for any help you might give.
checkout-tpl.txt
customer-checkout-tpl.txt
0
Comment
Question by:stoneycurtis
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:girionis
Comment Utility
Can you only try "checked" instead of "'checked="checked"'"?
0
 

Author Comment

by:stoneycurtis
Comment Utility
Hello Girionis,
1)
<label><input type="radio" name="register" value="1"<?php echo $register == 1 ? "checked" :' '; ?>reload="customer_register" /><b><?php echo $text_yes ?></b>&nbsp;<b><?php echo $text_register; ?></b>&nbsp;</label></br>

Open in new window

Doesn't allow the reload to work.
2 )
<label><input type="radio" name="register" value="1"<?php echo $register == 1 ? "checked"; ?>reload="customer_register" /><b><?php echo $text_yes ?></b>&nbsp;<b><?php echo $text_register; ?></b>&nbsp;</label></br>

Open in new window

Breaks the page entirely, (white screen).
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
Comment Utility
Need a space between vale="1" and checked.  As written, both of these create:
   value="1"checked
Add a space after the last double-quote and see if that helps.
0
 

Author Comment

by:stoneycurtis
Comment Utility
@ Girionis and BillBach
'checked="checked"' is the only way that the reload function will work.
<label><input type="radio" name="register" value="1" <?php echo $register == 1 ? 'checked="checked"' :''; ?>reload="customer_register" /><b><?php echo $text_yes ?></b>&nbsp;<b><?php echo $text_register; ?></b>&nbsp;</label></br>
                      <p><?php echo $text_register_account; ?></p>
                     <label><input type="radio" name="register" value="0" <?php echo $register == 0 ? 'checked="checked"' : ''; ?>reload="customer_not_register" /><b><?php echo $text_no ?>&nbsp;<?php echo $text_guest; ?></b></label>

Open in new window


Thanks for your help
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
You should accept billback's comment as answer. You need to leave a space between the value and the "checked" attibute.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now