X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Add radio button choice in New Profile page (https://forum.x-cart.com/showthread.php?t=56963)

bjt 12-09-2010 05:27 AM

Add radio button choice in New Profile page
 
My customer wants to give away a free product upon a new user registering. I've added a custom field entitled "Free gift" and made it a select box with two choices.
What I'd really like to do is make the choices radio buttons instead and include an image of the two products.
So far I have tried adding the two images and the following in the register_additional_info.tpl

<tr>
{foreach from=$v.varients item=o}
<td align="center"><input type="radio" name="additional_values[{$v.fieldid}]" id="additional_values_{$v.fieldid}" value='{$o|escape}'{if $v.value eq $o} checked="checked"{/if}>{$o|escape}
{/foreach}
</tr>

I've basically copied the structure from the code to use a select box, but so far no luck in getting the radio buttons to display. Using standard select box works fine. Any help would be much appreciated.

Cheers,

Brett

peddler 12-13-2010 09:50 AM

Re: Add radio button choice in New Profile page
 
I can't say for certain, but first glance makes me wonder if your "{if $v.value eq $o}" code is trying to set both radio buttons to checked status?

If so, that's the reason for non-display. Using Name and ID can have strange effects as well, depending upon whether the variables change or stay the same. You want the same name for more than one radio button, if you want to force a choice between the buttons.

Without knowing the variables involved, it's difficult to diagnose, at least for me. Maybe you could look at the page's source code and get a better idea of what the variables end up resolving to, alphanumerically.

hth

bjt 12-13-2010 10:16 PM

Re: Add radio button choice in New Profile page
 
Once again, thanks very much Ralph.
Having both radio buttons selected was part of the problem. The rest was caused by trying to nut this out way too late at night.
One problem was a mis-spelling of the word variant and the other thing I missed was a closing <td>

Here is the working solution:
{foreach from=$v.variants item=o}
<td align="center"><input type="radio" name="additional_values[{$v.fieldid}]" id="additional_values_{$v.fieldid}" value='{$o|escape}'>{$o|escape}</td>
{/foreach}

Kind regards,
Brett


All times are GMT -8. The time now is 05:53 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.