Solved

Radio Button Checked Value

Posted on 2014-11-13
5
276 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
ID: 40442409
Can you only try "checked" instead of "'checked="checked"'"?
0
 

Author Comment

by:stoneycurtis
ID: 40442495
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
ID: 40442601
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
ID: 40442811
@ 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
ID: 40444186
You should accept billback's comment as answer. You need to leave a space between the value and the "checked" attibute.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

863 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

24 Experts available now in Live!

Get 1:1 Help Now