Site maintenance: Sun 15 Nov, from 12:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / Setting Up Categories, Products, Attributes / How to force selection of a checkbox?

How to force selection of a checkbox?

Locked

Started by karma_lab on 3 Jun 2008, 10:26 PM · Views: 3,292

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
3 Jun 2008, 10:26 PM
#1
karma_lab avatar

karma_lab

Zen Follower

Join Date:
Apr 2008
Posts:
135
Plugin Contributions:
0

How to force selection of a checkbox?

I know the "trick" for forcing selection of one of several radio buttons (make an additional one named "please select", mark it display only, and make it the default as explained here: http://www.zen-cart.com/forum/showthread.php?t=95520)

However, this same thing does not work for checkboxes, not in the same way.

I want to have 5 checkboxes for the user to indicate which of several models of a product they may own. They can specify more than 1, but they must at least pick 1.

So if I try the "trick" method above, it will not force the user to pick one; the product will be added to the cart, and then the cart will say that invalid options have been selected and you need to go back and fix them. It doesn't tell you what is wrong specifically. This is much worse than what happens with the radio buttons or drop downs, where it will not allow you to add the product to the cart and it tells you exactly which option needs to be selected.

I suspect that this will not work due to the nature of checkboxes, and if so, any hints on where to modify the code to fix this would be helpful.

4 Jun 2008, 2:40 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to force selection of a checkbox?

At this time, there isn't a way to force a selection on the checkboxes ...

This is something we are looking into for a future release ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 Jun 2008, 4:11 AM
#3
karma_lab avatar

karma_lab

Zen Follower

Join Date:
Apr 2008
Posts:
135
Plugin Contributions:
0

Re: How to force selection of a checkbox?

I had a feeling you were going to say that. ;)

I hope when you are working on this, you all will consider a redesign of the way this whole issue works, with regards to any type of option selection. The rigamarole that people have to go through to get this to work on radio buttons and drop downs is very klugey (as discussed in the thread referenced above.)

By way of example, I am moving to using ZC from having used MIVA for a store for many years. The way they do it is quite elegant and you should use it as some sort of a model.

Basically, there is a setting for an attribute named "required". If you check "required", then the user is forced to make a selection, regardless of what type of UI object it is. You can specify one of the options to be the default, and in that case, the default is pre-selected unless the user chooses something else. But ticking the "required" setting on the attribute controls the whole behavior - no need to make extra option values and try to hide them (as discussed in the thread referenced above.)

In your case, it seems this would be a setting in the Option Names section. You simply tick the "required" checkbox on the option name, and it then will not allow the user to add the item to the cart without making a selection of one of the option values (or one or more, in the case of a group of checkboxes in the same attribute.)

Thanks!

5 Jun 2008, 6:09 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to force selection of a checkbox?

Thanks for the suggestion ... :smile:

We know that this is lacking in the attributes and do plan to address it in a future release as, quite frankly, the dang thing drives us nuts as well ... :blink:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!