We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    Is it posible to insert getdata from the browser adres into a textfield? I used it befor with a form snippet like this:

    www.nicedomainname.com/nicealias.html?domain=modxcms.com
    then I put this in the top of the snippet

    $domain = $_GET[’domein’];
    $emailForm = $modx->getChunk(’EmailForm’);
    $emailForm = str_replace("[+domain+]", $domain, $emailForm);

    is this posible in eform using the chunks as template? where do I pars the get input? in eform snippet or in the eform.inc.php or can I add somthing to the chunk to make this work?

    Thanks for the help

    Dimmy
      follow me on twitter: @dimmy01
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The oddest thing just happened. I was going to modfy the eform snippet to allow for smtp mailing, and when I clicked on the Save button the frame ended up with my home page. An examination of the frame showed that it had the usual url for a bad link (http://www.sottwell.com/home?refurl=%2Findex.php%3Fq%3D403.shtml&err=1). So I tested a few things. I can save literally everything else on the site, snippets, documents, chunks, TVs, you name it. I deleted the snippet code. Saved the empty snippet fine. So I pasted in the code from the original download. Back to the home page in the frame. This is in a sub-folder installation, so I tried it in the main installation; same thing. I used the installer to install it the first time, so didn’t notice the problem.

      I’ve checked with a different host that is using the snippet, and there’s no problem editing and saving the snippet. Really strange.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 727
        • 502 Posts
        Manually fix the bug so you can use the advanced toolbar when editing a chunk. Then you can create a table and add the form elements.
        For the very simple fix see the thread on creating forms with chunks started by me.

        Andy
          • 16095
          • 35 Posts
          First of all thank you xwisdom for the snippet and dimmy for your help to make it work for me.

          I thought I could post here some code for validating a listbox as a required field and retaining listbox values after validation fails somewhere else in the form.

          This code worked for me and could work for other people new to MODx like myself so that they can save some time and frustration.

          1.- Validation of a listbox as a required field (the key is here: <option value="">):

          <select id="especie" name="especie" >
          <option value="">Seleccione una opción </option>
          <option value="perro">Perro</option>
          <option value="gato">Gato</option>
          <option value="indiferente">Indiferente</option>
          </select>

          The snippet call:

          &format=` especie:Especie:listbox:1 `

          2.- Retaining the value after validation fails somewhere else (JavaScript). Place the code just before the end of the form (just before the </fom> tag):

          <script>
          for (i = 0; i < document.forms[0].especie.options.length; i++)
          {
          if (document.forms[0].especie.options[i].value == "[+especie+]")
          {
          document.forms[0].especie.selectedIndex = i;
          break;
          }
          }
          </script>

          Of course, change the 4 “especie” instances by your list name.

          3.- I would really appreciate it if someone could tell me how to keep the text input by an user in a textarea after a validation fails so that the user does not have to enter the whole text again (just like it does with <input type="text">).
            • 7455
            • 2,204 Posts
            Quote from: knud at May 18, 2006, 07:49 AM


            3.- I would really appreciate it if someone could tell me how to keep the text input by an user in a textarea after a validation fails so that the user does not have to enter the whole text again (just like it does with <input type="text">).


            thats easy like this:

            <textarea tabindex="8" rows="5" cols="30" name="message">[+message+]</textarea>

            greets Dimmy
              follow me on twitter: @dimmy01
              • 16095
              • 35 Posts
              Thank you again Dimmy,

              My mistake was to do it like this:

              <textarea tabindex="8" rows="5" cols="30" name="message" [+message+]></textarea>
                • 33372
                • 1,611 Posts
                Quote from: knud at May 18, 2006, 07:49 AM

                <script>
                for (i = 0; i < document.forms[0].especie.options.length; i++)
                {
                if (document.forms[0].especie.options[i].value == "[+especie+]")
                {
                document.forms[0].especie.selectedIndex = i;
                break;
                }
                }
                </script>
                Thanks for pointing out this solution.

                I had better luck with this script:
                <script type="text/javascript">
                for (i=0; i<document.forms[0].service.options.length; i++){
                   if (document.forms[0].service.options[i].value == "[+service+]"){
                      document.forms[0].service.selectedIndex = i;
                      break;
                   }
                }
                </script>

                In case anyone else is struggling with this.
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 22303 MODX Staff
                  • 10,725 Posts
                  FYI, that code is actually identical other than the valid script element type attribute; the [ i ] index is hidden in the quoted code due to BBCode, but not in the code block. So, just a friendly reminder for everyone to place code in code blocks rather than quotes.

                  Cheers
                    • 33372
                    • 1,611 Posts
                    So that’s what happened...

                    This also works with a getElementById method (assuming you add an id tag to your select menu).

                    I couldn’t get the snippet to do this on its own using the syntax described earlier in this thread (and I tried all morning).
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 16095
                      • 35 Posts
                      Ooops! Sorry about that. The code I used is:
                      <script>
                         for (i = 0; i < document.forms[0].especie.options.length; i++)
                         {
                            if (document.forms[0].especie.options[i].value == "[+especie+]")
                            {
                               document.forms[0].especie.selectedIndex = i;
                               break;
                            }
                         }
                      </script>

                      This discussion is closed to further replies. Keep calm and carry on.