We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3763
    • 155 Posts
    Hello @ all!

    When I use the manger and edit a snippet for example, hit "save", the complete form input elements are disabled but the data is still sent.
    I want to add this to a snippet but it’s not working as supposed. Generally, when you set a form or input field as disabled, it’s value is not submitted, but in the manger it is.

    From the source code I could grab this:
    function saveWait(fName) {
       document.getElementById("savingMessage").innerHTML = "Saving, please wait...";
       for(i = 0; i < document.forms[fName].elements.length; i++) {
          document.forms[fName].elements[i].disabled='disabled';
       }
    }


    Now I have for example a simple page like this:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>My Test</title>
      <script language="javascript" type="text/javascript">
      /* <![CDATA[ */
       function saveWait(fName) {
          document.getElementById("savingMessage").innerHTML = "Saving, please wait...";
          for(i = 0; i < document.forms[fName].elements.length; i++) {
             document.forms[fName].elements[i].disabled='disabled';
          }
       }
    
      /* ]]> */
      </script>
    </head>
    <body>
       <?php
          foreach ($_POST as $key => $value)
             echo "{$key} = {$value}<br />";
       ?>
       <span class="warning" id='savingMessage'></span>
       <form method="post" name="test" onsubmit="saveWait('test');">
          <input type="text" name="Name" size="40" maxlength="255" /><br />
          <input type="text" name="Email" size="40" maxlength="255" /><br />
          <input type="submit" name="Submit" value="submit" />
       </form>
    </body>
    </html>

    The JavaScript disables nicely the form, but I get no values back. How is MODx manager doing this? If I remove the JavaScript the form is submitting good.

    Thank you very much!
    Regards, Boby.
      ...my Photo Gallery on Flickr...
    • I had a similar problem, the form with disabling worked just great on every browser except (can you guess?) IE. I ended up having to remove the disabling javascript.

      There is an interesting discussion on this using the Prototype library. http://particletree.com/notebook/eventstop/#5779
        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
        • 3763
        • 155 Posts
        Thank you Susan. This was of great help smiley

        Ok, I’ve come so far that I read all the submition in an array:
        allElem = Form.getElements('MyForm');

        Then I disable the form with:
        Form.disable('MyForm');

        All good ’till now, but how do I send now the array as submit? I have not found this sad

        Thanks, Boby.
          ...my Photo Gallery on Flickr...