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: http://tnpublichealth.org/membership-information/membership-form/
Here is the code as a downloadable snippet: http://lemurhost.com/media/member-snippet.txt

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?

Comments
  • 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,

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

    &nbsp;

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


    becomes:


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


    and for radio buttons becomes something like:


    <strong>Gender:</strong>
    <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.