Solved

Radio Button Checked Value

Posted on 2014-11-13
5
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Make the most of your online learning experience.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

617 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