Solved

Radio Button Checked Value

Posted on 2014-11-13
5
282 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Let’s list some of the technologies that enable smooth teleworking. 
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

839 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