• <?php $selected = get_the_author_meta('user_farbe', $user->ID);?>
    <select name="user_farbe" id="user_farbe">
    <option value="Farbe gespeichert" <?php echo ($selected == "Farbe gespeichert")?  'selected="selected"' : '' ?>>Farbe gespeichert</option>
    <option value="1./Farbe 1" <?php echo ($selected == "1./Farbe 1")?  'selected="selected"' : '' ?>>2. Farbe</option>
    <option value="2./Farbe nach dem&#10Kasten; 1" <?php echo ($selected == "2./Farbe nach dem
    Kasten 1")?  'selected="selected"' : '' ?>>2. Farbe</option>
    <option value="3./Farbe 1" <?php echo ($selected == "3./Farbe 1")?  'selected="selected"' : '' ?>>3. Farbe</option>
    <option value="4./Farbe 1" <?php echo ($selected == "4./Farbe 1")?  'selected="selected"' : '' ?>>4. Farbe</option>
    </select>

    1 Farbe works and stays selected when selected
    2 Farbe works but doesnt stay selected -> it says Farbe gespeichert
    3 Farbe works and stays selected if chosen
    4 Farbe works and stays selected if chosen

    Why does “3 Farbe” not select itself after chosen?

    Is it because of the ?

    Thanks a lot you hardcoreCoder : )

Viewing 1 replies (of 1 total)
  • I would recommend not using line breaks in value attributes. This also makes it easier for browsers to pass the value cleanly.

    If you still want to try it, use in the if condition instead of a real newline. Also compare via var_dump() what values you actually get there.

    By the way, this topic has nothing to do with WordPress. You can also ask the question in a forum for PHP development, e.g. here: https://stackoverflow.com/

Viewing 1 replies (of 1 total)
  • The topic ‘line break prevents select’ is closed to new replies.