The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Making attributes 'pick 1' only

About 9 years ago this forum helped me set up my first form for Foxycart. I need to make one change and I'm not 100% sure the safest way to do it given we are using attributes.

We are on Store version 2.0

Here is the page:
Here is the code as a downloadable snippet:

I am looking to make the "section" add-ons (attributes in Foxycart terms) limited to one - people are selecting multiples and it's causing some headaches.

Any thoughts on how to do this effectively without breaking it?

  • fc_marijafc_marija FoxyCart Team
    Hi @careycat

    If i'm understanding you correctly, you'll want to change the add-ons to a dropdown or radio buttons rather than checkboxes. As you've noticed, checkboxes allow the customer to select more than one option, whereas a dropdown or radio button will allow only one selection within that element. Probably the main determinant as to which one you'd want to use is whether or not you want all possible values to be displayed or if you want the user to have to click to to see the list of choices.

    Using a dropdown and example from your code,

    <br />
    <input class="small" id="3:Demo Gender" name="3:Demo Gender" type="checkbox" value="3:DemoMale{p+0}" />


    <input class="small" id="3:Demo Gender2" name="3:Demo Gender2" type="checkbox" value="3:DemoFemale{p+0}" />
    Female &nbsp; &nbsp; &nbsp;</strong></p>


    <br />
    <select class="small" id="3:Demo Gender" name="3:Demo Gender" >
    <option value="Male">Male</option>
    <option value="Female">Female</option>

    and for radio buttons becomes something like:

    <br />
    <input type="radio" class="small" name="3:Demo Gender" value="Male" />
    <input type="radio" class="small" name="3:Demo Gender" value="Female" />

    Note that for radio buttons, the name of a set of options needs to be the same in order to have the radio buttons for each option only allow 1 selection.

    As an aside, I'm curious as to why (from a business perspective), for example, demographics, are set up to be added as a separate product as opposed to an option on the the product. Perhaps this is by design–if so, I'd love to hear more about it so I can increase my understanding of how you're using FoxyCart.
Sign In or Register to comment.