We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14660
    • 11 Posts
    I’m currently using the registration page from the Login package. I know that there is a way to keep the text field value when you click submit and it returns to the page. For example, if you type in your username and you submit, your username will still be there if it fails the validation process.

    <input type="text" name="username" id="username" value="[[+username]]" />


    Is there a way to do something like this for <select> tags? In other words, for the drop-down menu.
      • 1778
      • 659 Posts
      Hi,
      Yep ... the same way
      as example
      <select id="mySelect" name="mySelect" value="[[+mySselect]]">
        <option id="opt1" name="opt1" value="opt1">OPT 1</option>
        <option id="opt2" name="opt2" value="opt2">OPT 2</option>
      </select>
      


      It should work...
      Cheers
        • 14660
        • 11 Posts
        Nope, doesn’t work for me embarrassed

        <select name="title" id="title" value="[[+title]]">
          <option name="" value=""></option>
          <option id="Mr" name="Mr" value="Mr">Mr</option>
          <option id="Mrs" name="Mrs" value="Mrs">Mrs</option>
          <option id="Mdm" name="Mdm" value="Mdm">Mdm</option>
          <option id="Ms" name="Ms" value="Ms">Ms</option>
        </select>


        Am I missing anything from there?
          • 1778
          • 659 Posts
          Hello

          You can try that, I read too fast the first time, did not understand that you want to retain the select value if the form is submitted and fails the validation process

          <select id="mySelect" name="mySelect" value="[[+mySselect]]">
            <option id="opt1" name="opt1" value="opt1" [[+mySelect:is=`opt1`:then=`selected="selected"]]>OPT 1</option>
            <option id="opt2" name="opt2" value="opt2" [[+mySelect:is=`opt2`:then=`selected="selected"]]>OPT 2</option>
          </select>
          


          Should work this time as you expect it... Let me know..
          Hope this helps
          Cheers
            • 14660
            • 11 Posts
            Nope, still doesn’t work for me.

            <select name="title" id="title" value="[[+title]]">
             <option value=""></option>
             <option id="Mr" name="Mr" value="Mr" [[+title:is=`Mr`:then=`selected="selected"]]>Mr</option>
             <option id="Mrs" name="Mrs" value="Mrs" [[+title:is=`Mrs`:then=`selected="selected"]]>Mrs</option>
             <option id="Mdm" name="Mdm" value="Mdm" [[+title:is=`Mdm`:then=`selected="selected"]]>Mdm</option>
             <option id="Ms" name="Ms" value="Ms" [[+title:is=`Ms`:then=`selected="selected"]]>Ms</option>
            </select>


            Do I need to perform any extra validation or install any other package? I’m currently using the Login package to do this.
              • 1778
              • 659 Posts
              How do you call your snippet ?
              Cheers
                • 14660
                • 11 Posts
                Here is how I call my snippet:

                [[!Register?
                  &activationResourceId=`18`
                  &activationEmailTpl=`lgnActivateEmailTpl`
                  &successMsg=`You have successfully registered your account`
                  &submitVar=`registerbtn`
                  &preHooks=`validateRegistration`
                  &postHooks=`autoFillAttributes`
                ]]
                  • 1778
                  • 659 Posts
                  Hi,

                  I’m not sure at all, but it’s possible that your field name ("title") causes some trouble here... Did you try to give it another id and another name (avoid using ’title’ or other words used (reserved?) by modx )?

                  Just in case...

                  Cheers
                    • 14660
                    • 11 Posts
                    Nevermind, it’s fine now. I was missing a little syntax there, if you look at it properly.

                    Thanks for your help though wink