Support

Account

Home Forums General Issues Select choice : multiple if

Helping

Select choice : multiple if

  • Hi,

    I created one “Select choice” field.
    Then, multiple “Text fields” with conditional logic from the select choice.
    I don’t know how to get the fields on my PHP file.

    My fields look like this :
    – Select choice field : values A,B,C,D,E (only one choice possible)
    – Text field 1 : Lorem ipsum 1
    – Text field 2 : Lorem ipsum 2
    – Text field 3 : Lorem ipsum 3

    I would need to get the fields this way :

    IF “Select choice” value is A or B
    <div some code here> display> “Text field 1” </div>

    IF “Select choice” value is A or B or C or D
    <div some code here> display> “Text field 2” </div>

    IF “Select choice” value is B or C or D or E
    <div some code here> display> “Text field 3” </div>

    Hope it’s clear enough. If anybody could help, would be great !
    I’m stuck on that since days…

  • 
    $value = get_field('select_field');
    if (in_array(array('A', 'B'), $value)) {
    	the_field('text_field_1');
    }
    if (in_array(array('A', 'B', 'C', 'D'), $value)) {
    	the_field('text_field_2');
    }
    if (in_array(array('B', 'C', 'D', 'E'), $value)) {
    	the_field('text_field_3');
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Select choice : multiple if’ is closed to new replies.