Support

Account

Home Forums Backend Issues (wp-admin) Checkboxes with same value

Solved

Checkboxes with same value

  • Hi all,

    I need to create a checkbox element with various choices with the same value. Like this one.

    grey : Dark grey
    grey : Light grey

    This is not possible because every choice in the checkbox has to have a unique value label set.

    Is there any way to remove this limitation, even if I have to modify the core function that checks for the uniqueness of this values?

    Many thanks.

  • No, there isn’t any way to remove the limitation due to the way ACF stores the values for the choices.

  • Ok, so I have a problem.

    I’m working on a front-end form that calculates prices, I have a lot of items with a price and everyone has a checkbox for add/remove.
    For example:

    100 : Lights
    100 : Brakes
    300 : Engine

    Where the number is the price and the name is the product. Then if you have selected Lights and Engine I calculate via javascript the total of 400.
    My problem, as you see, is that if I have two products with the same price only one will be stored.

    You know any way to store the price and the product name? like saving the price into another attribute apart from the value?

    Thank you.

  • Nothing simple, it all depends on how you’re storing the items that you want to calculate on. If the only place they are stored is in the field, then no. There isn’t any type of ACF field that allows selections that can hold the same value for more than one of them. I think I answered another similar question

    Try something like

    
    100 : 100
    100.0 : 100
    100.00 : 100
    100.000 : 100
    

    the left side should all evaluate to 100 but be considered different values for the array.

  • Thank you John.

    Finally I’ve included the price in the label with a separator character and then, get them with javascript and put into the checkbox value attribute.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Checkboxes with same value’ is closed to new replies.