• Resolved dawnrae

    (@dawnrae)


    I am a bit confused on applying conditional statements between values of two Select field (single option).

    The fields optional ones. They might both have values or only one may, and sometimes neither will have a value and I wish to apply a text field value instead.

    Here are the fields

    $select_1 = $cfs->get('select_1', $post_id);
    $select_2 = $cfs->get('select_2', $post_id);
    $text_field = $cfs->get('text_field', $post_id);

    I wish to check the fields and designate the output based on a “true/false” or presence of a value, and set an order in which they should be checked:

    Here’s an example :

    if($select_1==true) { echo foreach($select_1 as $value => $label) { echo $value; } }
    elseif($select_2==true) { echo foreach($select_2 as $value => $label) { echo $value; } }
    else { echo $text_field; }

    NOTE: I’ve tried this code with and without using “echo”

    If select_1 should have a value, I’d like it to ignore the other options.
    If select_1 doesn’t have a value, I’d like it to check select_2 for a value.
    If select_1 and select_2 don’t have a value, I’d like to display the text_field value.

    Right now, I can get it to check a single value and render properly, but when I attempt to apply the if/else in regards to the secondary select field, it will only retrieve one.

    Do you have have any suggestions on how to get this to work the way I need?

    Thank you

    • This topic was modified 7 years, 11 months ago by dawnrae.
  • The topic ‘Conditional Statements and Multiple Select’ is closed to new replies.