Jump to content

How to have specific selected options not to be repeated


Recommended Posts

Hello fellow geeks!

So I have 5 options with numbers 1-70 and one additional option where the customer must select one number 1-25. So, for the first 5 options, the customer cannot select the same number twice, for example, he can choose 4-9-26-7-10 but he cannot choose 4-9-26-7-4-10. Then he has the last (6th) option, where he can choose number 1-25 and since this is not related to the first 5 options, he can choose any number (1-25) regardless if it was chosen on the prior options. How to enforce this behavior?

norepeat.gif

Also, since we are talking about options, when someone places an order, how to have the options selected displayed on incremental?

sorting.jpg

Greatly appreciated in advance!

cheers,

AJ

 

Edited by AeroLogistica
typo
Link to comment
Share on other sites

There is a form validator that could be enhanced to make sure any one selection is not the same as any other selection.

There is also the idea of making that option as a set of checkboxes (there would need to be a custom layout) where any five can be checked. But CubeCart is not yet fully coded to show checkboxes.

There is also the idea of a single text field where the numbers can be entered, separated by a space, comma, or dash (there would need to be a custom verification), where the label says "Enter five different numbers between 1 and 70". (I think this is the easiest.)

 

Edited by bsmither
Link to comment
Share on other sites

Currently, I am not finding a way to make any one specific Option Group (for example, "PowerBall #1") have a relationship to any other specific Option Group(s) (for example, "PowerBall #2", etc).

I am still experimenting.

Link to comment
Share on other sites

40 minutes ago, bsmither said:

Currently, I am not finding a way to make any one specific Option Group (for example, "PowerBall #1") have a relationship to any other specific Option Group(s) (for example, "PowerBall #2", etc).

I am still experimenting.

Maybe JavaScript to handle the interaction between the selected option and the corresponding action or data?

Link to comment
Share on other sites

That would be the solution, but what would be a common attribute among the five selectors, and yet not include the sixth selector?

Each selector is a distinct "option" (an option group of attributes) in its own right. There is nothing to relate them as a collection.

"handle the interaction between the selected option and the corresponding action or data"

The customer selects and option from the selector. But what do you mean by "corresponding action or data"?

Link to comment
Share on other sites

Hoe about if instead of validating for non repeating values, it checks once the selection is made, in case of repetitive values, the customer will get a warning but we'll have the same issue because of how to exclude option sixth? This one can be repetitive as it's "different" from the other 5, so, how to exclude it?

Link to comment
Share on other sites

@bsmither my friend mentioned about a set in Javascript:

Set objects are collections of values. A value in the set may only occur once; it is unique in the set's collection. You can iterate through the elements of a set in insertion order. I just don't have a clue on how to implement it.

Link to comment
Share on other sites

The "#id select" might not be what you want.

Maybe "#id option:selected". This should find all selected options from the specific DOM node having id="id". (So, this selector may need to be set to 'multiple' to allow to choose five options.)

Or maybe "[id^='maingroup'] option:selected". This should find all selected options from the group of selectors having id="maingroup_no1", where no1 is the specific id of the first selector, and no2 is the specific id of the second selector, etc. The format id^='maingroup' means that the id must start with maingroup, and jQuery will find all of them. Then .each() will work on them in turn.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...