We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30884
    • 142 Posts
    Hi there,

    I’ve not been here for a while but this is really quite perplexing me right now. I’m not able to inject the meta tag of SELECTED into the <option value="blah">Blah</option> html using PHP below!?! Am I doing something wrong? Is Modx 0.95 actually removing something from the output? Is having the $selected="" confusing things on the next loop?

    Most confused! Any help or pointers most appreciated.

    <?php
     if ($resmatch<>""){
     $selected ="SELECTED";
    } else {
    $selected = "";
    }
     $option_dropdown = $option_dropdown . 
    		"<OPTION  ".$selected." value='" . $res_choice[Preset_Resolution_id] ."'>"
    		. $res_choice[Preset_Resolution_Name] ."</option>";
    ?>
    


    which is in a loop which populates the dropdown with MySQL query results which is working fine.

    <td>Select resolution </td>
    <td><select name="resolution_choice" id="resolution_choice" >
    <option value="0" > Current Res - 1280x720</option>
    <option value='1' >720p - 1280x720</option>
    <option value='2' >1080p - 1920x1080</option>
    <option value='3' >PAL - Widescreen - 1024x576</option>
    <option value='4' >NTSC - Widescreen - 816x480</option>
    <option value='13' >Digital cinema 2k - film -2048x848</option>
    <option value='11' >Digital cinema 4k - film - 4096x1714</option>
    </select>
    </td>
    
      p i x e l p u s h e r e x t r o d i n a i r e
      A x i s A n i m a t i o n . c o m
      • 16034
      • 107 Posts
      Perhaps its the <> that’s wrong? I don’t know what that does in PHP. Not equal is !=.
      <?php
       if ($resmatch!=""){
      ...
        MODx snippet-glossary 101:
        Ditto = Content Lister -- Wayfinder == Menu Builder -- Jot = Comment Control
        • 30884
        • 142 Posts
        It’s not the <> (which is also not equal notation) since I can actually hard code one of the lines in another option drop down to include SELECTED in it and it get’s removed at runtime!

        <option SELECTED value="Test">Test Text - SELECTED</option>
        


        (is the result I want)

        becomes

        <option value="Test">Test Text - SELECTED</option>
        


        The variable I drop into the second half of the text line is the same string I drop into the <option> tag at the start. The text dialog SELECTED stays but the option tag SELECTED gets removed. If I (on-purpose) mis-spell the string to be something other than SELECTED it shows up!?

        Most confusing and I’m now more curious about why this is happening as opposed to frustrated now since I’m going to make do with a work around of some sort but it’s not as good as auto SELECTING the value that’s being editted in the database.

        Cheers

        TxRx
          p i x e l p u s h e r e x t r o d i n a i r e
          A x i s A n i m a t i o n . c o m
          • 4310
          • 2,310 Posts
          I seem to remember having a similar issue sad
          Have you tried
          selected="selected"
          rather than just
          SELECTED

            • 30884
            • 142 Posts
            That’s the very thing!!! I cannot thank you enough David!
            Superb!!

            Many thanks!!!

            TxRx
              p i x e l p u s h e r e x t r o d i n a i r e
              A x i s A n i m a t i o n . c o m