Loading ...
Sorry, an error occurred while loading the content.

[ydn-javascript] access form values from dialog handleSubmit

Expand Messages
  • Martin Tschofen
    How can I access the form values in the success handler of a dialog? I tried: var handleSubmit = function () { alert(this.getData().titleField; this.hide; }
    Message 1 of 6 , Dec 12, 2006
    • 0 Attachment
      How can I access the form values in the success handler of a dialog?

      I tried: 

      var handleSubmit = function () {
         alert(this.getData().titleField;
         this.hide;
      }

      titleField is defined inside a form inside the dialog:
      <textarea name="titleField"></textarea>

      The dialog displays. After submitting I get "undefined".

      I can access the data from within the validate function, perhaps I need to parse the elements in the dialog itself.

      Thanks...martin
    • Steven Peterson
      Martin, This code looks right except for the missing parenthesis after titleField . I tried it on my own and it works fine. Can you provide your full code so
      Message 2 of 6 , Dec 12, 2006
      • 0 Attachment

        Martin,

         

        This code looks right except for the missing parenthesis after “titleField”. I tried it on my own and it works fine. Can you provide your full code so that I can see if something else may be causing your issue?

         

        Thanks!

         

        Steven Peterson

        Web Developer, Platform Engineering

        Yahoo!

         

         

         

        From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Martin Tschofen
        Sent: Tuesday, December 12, 2006 2:51 PM
        To: ydn-javascript@yahoogroups.com
        Subject: [ydn-javascript] access form values from dialog handleSubmit

         

        How can I access the form values in the success handler of a dialog?

         

        I tried: 

         

        var handleSubmit = function () {

           alert(this.getData().titleField;

           this.hide;

        }

         

        titleField is defined inside a form inside the dialog:

        <textarea name="titleField"></textarea>

         

        The dialog displays. After submitting I get "undefined".

         

        I can access the data from within the validate function, perhaps I need to parse the elements in the dialog itself.

         

        Thanks...martin

      • Martin Tschofen
        Here s what I have. When I add parens to the titleInfo, I get an error that the result is not an object. Thanks for looking into this...martin
        Message 3 of 6 , Dec 12, 2006
        • 0 Attachment
          Here's what I have.

          When I add parens to the titleInfo, I get an error that the result is not an object.

          Thanks for looking into this...martin


          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " http://www.w3.org/TR/html4/strict.dtd">
          <html>
              <head>
          <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
          <title>dialog</title>

                 
                  <link type="text/css" rel="stylesheet" href="build/fonts/fonts.css">
                  <link type="text/css" rel="stylesheet" href="build/reset/reset.css">

                  <script type="text/javascript" src="build/yahoo/yahoo.js"></script>
                  <script type="text/javascript" src="build/event/event.js" ></script>
                  <script type="text/javascript" src="build/dom/dom.js" ></script>
                  <script type="text/javascript" src="build/dragdrop/dragdrop.js" ></script>
                  <script type="text/javascript" src="build/connection/connection.js" ></script>

                  <script type="text/javascript" src="build/container/container.js"></script>
                  <link type="text/css" rel="stylesheet" href="build/container/assets/container.css">
                 
                  <style>
                      body { background:#eee }
                      label { display:block;float:left;width:45%;clear:left; }
                      .clear { clear:both; }
                      #resp { font-family:courier;margin:10px;padding:5px;border:1px solid #ccc;background:#fff;}
                  </style>

                  <script>
                          YAHOO.namespace("test.container");

                          function init() {
                             
                              // Define various event handlers for Dialog
                              var handleSubmit = function() {
                                  alert(this.getData().titleInfo());
                                  this.hide();
                              };
                              var handleCancel = function() {
                                  this.cancel ();
                              };

                              // Instantiate the Dialog
                              YAHOO.test.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
                              { width : "300px",
                                fixedcenter : true,
                                visible : false,
                                modal : true,
                                postmethod : 'manual',
                                constraintoviewport : true,
                                buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
                                            { text:"Cancel", handler:handleCancel } ]
                               } );
                                                 
                              // Render the Dialog
                              YAHOO.test.container.dialog1.render();

                              YAHOO.util.Event.addListener("show", "click", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1, true);
                              YAHOO.util.Event.addListener("resp", "dblclick", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1 , true);
                          }

                          YAHOO.util.Event.addListener(window, "load", init);
                  </script>

              </head>
              <body>
                  <div>
                      <button id="show">Show dialog1</button>
                      <button id="hide">Hide dialog1</button>
                  </div>

                  <div id="dialog1">
                      <div class="hd">Please enter your information</div>
                      <div class="bd">
                          <form method="POST" action="../assets/post.php">
                              <label for="textarea">Text area:</label><textarea name="titleInfo"></textarea>
                          </form>
                      </div>
                  </div>

                  <div id="resp">Server response will be displayed in this area</div>
              </body>
          </html>

          On 12/12/06, Steven Peterson <y_stevenp@...> wrote:

          Martin,

           

          This code looks right except for the missing parenthesis after "titleField". I tried it on my own and it works fine. Can you provide your full code so that I can see if something else may be causing your issue?

           

          Thanks!

           

          Steven Peterson

          Web Developer, Platform Engineering

          Yahoo!

           

           

           

          From: ydn-javascript@yahoogroups.com [mailto:ydn- javascript@yahoogroups.com] On Behalf Of Martin Tschofen
          Sent: Tuesday, December 12, 2006 2:51 PM
          To: ydn-javascript@yahoogroups.com
          Subject: [ydn-javascript] access form values from dialog handleSubmit

           

          How can I access the form values in the success handler of a dialog?

           

          I tried: 

           

          var handleSubmit = function () {

             alert(this.getData().titleField;

             this.hide;

          }

           

          titleField is defined inside a form inside the dialog:

          <textarea name="titleField"></textarea>

           

          The dialog displays. After submitting I get "undefined".

           

          I can access the data from within the validate function, perhaps I need to parse the elements in the dialog itself.

           

          Thanks...martin


        • Steven Peterson
          You were missing the right paren from your alert - you had: alert(this.getData().titleInfo; If you fix that, this example looks like it should work. Steven
          Message 4 of 6 , Dec 12, 2006
          • 0 Attachment

            You were missing the right paren from your alert – you had: alert(this.getData().titleInfo;

            If you fix that, this example looks like it should work.

             

             

            Steven Peterson

            Web Developer, Platform Engineering

            Yahoo!

             

             

            From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Martin Tschofen
            Sent: Tuesday, December 12, 2006 5:11 PM
            To: ydn-javascript@yahoogroups.com
            Subject: Re: [ydn-javascript] access form values from dialog handleSubmit

             

            Here's what I have.

            When I add parens to the titleInfo, I get an error that the result is not an object.

            Thanks for looking into this...martin


            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " http://www.w3.org/TR/html4/strict.dtd">
            <html>
                <head>
            <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
            <title>dialog</title>

                   
                    <link type="text/css" rel="stylesheet" href="build/fonts/fonts.css">
                    <link type="text/css" rel="stylesheet" href="build/reset/reset.css">

                    <script type="text/javascript" src="build/yahoo/yahoo.js"></script>
                    <script type="text/javascript" src="build/event/event.js"

            ></script>
                    <script type="text/javascript" src="build/dom/dom.js"
            ></script>
                    <script type="text/javascript" src="build/dragdrop/dragdrop.js"
            ></script>
                    <script type="text/javascript" src="build/connection/connection.js"
            ></script>

                    <script type="text/javascript" src="build/container/container.js"></script>
                    <link type="text/css" rel="stylesheet" href="build/container/assets/container.css">
                   
                    <style>
                        body { background:#eee }
                        label { display:block;float:left;width:45%;clear:left; }
                        .clear { clear:both; }
                        #resp { font-family:courier;margin:10px;padding:5px;border:1px solid #ccc;background:#fff;}
                    </style>

                    <script>
                            YAHOO.namespace("test.container");

                            function init() {
                               
                                // Define various event handlers for Dialog
                                var handleSubmit = function() {
                                    alert(this.getData().titleInfo());
                                    this.hide();
                                };
                                var handleCancel = function() {
                                    this.cancel ();
                                };

                                // Instantiate the Dialog
                                YAHOO.test.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
                                { width : "300px",
                                  fixedcenter : true,
                                  visible : false,
                                  modal : true,
                                  postmethod : 'manual',
                                  constraintoviewport : true,
                                  buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
                                              { text:"Cancel", handler:handleCancel } ]
                                 } );
                                                   
                                // Render the Dialog
                                YAHOO.test.container.dialog1.render();

                                YAHOO.util.Event.addListener("show", "click", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1, true);
                                YAHOO.util.Event.addListener("resp", "dblclick", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1 , true);
                            }

                            YAHOO.util.Event.addListener(window, "load", init);
                    </script>

                </head>
                <body>
                    <div>
                        <button id="show">Show dialog1</button>
                        <button id="hide">Hide dialog1</button>
                    </div>

                    <div id="dialog1">
                        <div class="hd">Please enter your information</div>
                        <div class="bd">
                            <form method="POST" action="../assets/post.php">
                                <label for="textarea">Text area:</label><textarea name="titleInfo"></textarea>
                            </form>
                        </div>
                    </div>

                    <div id="resp">Server response will be displayed in this area</div>
                </body>
            </html>

            On 12/12/06, Steven Peterson <y_stevenp@...> wrote:

            Martin,

             

            This code looks right except for the missing parenthesis after "titleField". I tried it on my own and it works fine. Can you provide your full code so that I can see if something else may be causing your issue?

             

            Thanks!

             

            Steven Peterson

            Web Developer, Platform Engineering

            Yahoo!

             

             

             

            From: ydn-javascript@yahoogroups.com [mailto:ydn- javascript@yahoogroups.com] On Behalf Of Martin Tschofen
            Sent: Tuesday, December 12, 2006 2:51 PM
            To: ydn-javascript@yahoogroups.com
            Subject: [ydn-javascript] access form values from dialog handleSubmit

             

            How can I access the form values in the success handler of a dialog?

             

            I tried: 

             

            var handleSubmit = function () {

               alert(this.getData().titleField;

               this.hide;

            }

             

            titleField is defined inside a form inside the dialog:

            <textarea name="titleField"></textarea>

             

            The dialog displays. After submitting I get "undefined".

             

            I can access the data from within the validate function, perhaps I need to parse the elements in the dialog itself.

             

            Thanks...martin

             

          • Martin Tschofen
            That was a typo. Without the ) I get a parse error. With it, I get the alert message undefined . alert(this.getData()); tells me it s an object. but
            Message 5 of 6 , Dec 12, 2006
            • 0 Attachment
              That was a typo. Without the ')' I get a parse error. With it, I get the alert message "undefined".

              alert(this.getData()); 

              tells me it's an object. but refering to titleInfo is undefined...martin

              On 12/12/06, Steven Peterson < y_stevenp@...> wrote:

              You were missing the right paren from your alert – you had: alert(this.getData().titleInfo;

              If you fix that, this example looks like it should work.

               

               

              Steven Peterson

              Web Developer, Platform Engineering

              Yahoo!

               

               

              From: ydn-javascript@yahoogroups.com [mailto:ydn- javascript@yahoogroups.com] On Behalf Of Martin Tschofen
              Sent: Tuesday, December 12, 2006 5:11 PM
              To: ydn-javascript@yahoogroups.com
              Subject: Re: [ydn-javascript] access form values from dialog handleSubmit

               

              Here's what I have.

              When I add parens to the titleInfo, I get an error that the result is not an object.

              Thanks for looking into this...martin


              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " http://www.w3.org/TR/html4/strict.dtd ">
              <html>
                  <head>
              <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
              <title>dialog</title>

                     
                      <link type="text/css" rel="stylesheet" href="build/fonts/fonts.css">
                      <link type="text/css" rel="stylesheet" href="build/reset/reset.css">

                      <script type="text/javascript" src="build/yahoo/yahoo.js"></script>
                      <script type="text/javascript" src="build/event/event.js" ></script>
                      <script type="text/javascript" src="build/dom/dom.js" ></script>
                      <script type="text/javascript" src="build/dragdrop/dragdrop.js" ></script>
                      <script type="text/javascript" src="build/connection/connection.js" ></script>

                      <script type="text/javascript" src="build/container/container.js"></script>
                      <link type="text/css" rel="stylesheet" href="build/container/assets/container.css">
                     
                      <style>
                          body { background:#eee }
                          label { display:block;float:left;width:45%;clear:left; }
                          .clear { clear:both; }
                          #resp { font-family:courier;margin:10px;padding:5px;border:1px solid #ccc;background:#fff;}
                      </style>

                      <script>
                              YAHOO.namespace("test.container");

                              function init() {
                                 
                                  // Define various event handlers for Dialog
                                  var handleSubmit = function() {
                                      alert(this.getData().titleInfo());
                                      this.hide();
                                  };
                                  var handleCancel = function() {
                                      this.cancel ();
                                  };

                                  // Instantiate the Dialog
                                  YAHOO.test.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
                                  { width : "300px",
                                    fixedcenter : true,
                                    visible : false,
                                    modal : true,
                                    postmethod : 'manual',
                                    constraintoviewport : true,
                                    buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
                                                { text:"Cancel", handler:handleCancel } ]
                                   } );
                                                     
                                  // Render the Dialog
                                  YAHOO.test.container.dialog1.render();

                                  YAHOO.util.Event.addListener("show", "click", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1, true);
                                  YAHOO.util.Event.addListener("resp", "dblclick", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1 , true);
                              }

                              YAHOO.util.Event.addListener(window, "load", init);
                      </script>

                  </head>
                  <body>
                      <div>
                          <button id="show">Show dialog1</button>
                          <button id="hide">Hide dialog1</button>
                      </div>

                      <div id="dialog1">
                          <div class="hd">Please enter your information</div>
                          <div class="bd">
                              <form method="POST" action="../assets/post.php">
                                  <label for="textarea">Text area:</label><textarea name="titleInfo"></textarea>
                              </form>
                          </div>
                      </div>

                      <div id="resp">Server response will be displayed in this area</div>
                  </body>
              </html>

              On 12/12/06, Steven Peterson <y_stevenp@...> wrote:

              Martin,

               

              This code looks right except for the missing parenthesis after "titleField". I tried it on my own and it works fine. Can you provide your full code so that I can see if something else may be causing your issue?

               

              Thanks!

               

              Steven Peterson

              Web Developer, Platform Engineering

              Yahoo!

               

               

               

              From: ydn-javascript@yahoogroups.com [mailto:ydn- javascript@yahoogroups.com] On Behalf Of Martin Tschofen
              Sent: Tuesday, December 12, 2006 2:51 PM
              To: ydn-javascript@yahoogroups.com
              Subject: [ydn-javascript] access form values from dialog handleSubmit

               

              How can I access the form values in the success handler of a dialog?

               

              I tried: 

               

              var handleSubmit = function () {

                 alert(this.getData().titleField;

                 this.hide;

              }

               

              titleField is defined inside a form inside the dialog:

              <textarea name="titleField"></textarea>

               

              The dialog displays. After submitting I get "undefined".

               

              I can access the data from within the validate function, perhaps I need to parse the elements in the dialog itself.

               

              Thanks...martin

               


               
            • Martin Tschofen
              I ve discovered that this is a Safari issue (2 as well as the latest webkit) as it works in firefox 2. Not sure what to do about it...martin ... I ve
              Message 6 of 6 , Dec 12, 2006
              • 0 Attachment
                I've discovered that this is a Safari issue (2 as well as the latest webkit) as it works in firefox 2. Not sure what to do about it...martin

                On 12/12/06, Martin Tschofen <martin.tschofen@...> wrote:
                That was a typo. Without the ')' I get a parse error. With it, I get the alert message "undefined".

                 
                alert(this.getData()); 

                tells me it's an object. but refering to titleInfo is undefined...martin


                On 12/12/06, Steven Peterson < y_stevenp@...> wrote:

                You were missing the right paren from your alert – you had: alert(this.getData().titleInfo;

                If you fix that, this example looks like it should work.

                 

                 

                Steven Peterson

                Web Developer, Platform Engineering

                Yahoo!

                 

                 

                From: ydn-javascript@yahoogroups.com [mailto: ydn- javascript@yahoogroups.com] On Behalf Of Martin Tschofen
                Sent: Tuesday, December 12, 2006 5:11 PM
                To: ydn-javascript@yahoogroups.com
                Subject: Re: [ydn-javascript] access form values from dialog handleSubmit

                 

                Here's what I have.

                When I add parens to the titleInfo, I get an error that the result is not an object.

                Thanks for looking into this...martin


                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " http://www.w3.org/TR/html4/strict.dtd ">
                <html>
                    <head>
                <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
                <title>dialog</title>

                       
                        <link type="text/css" rel="stylesheet" href="build/fonts/fonts.css">
                        <link type="text/css" rel="stylesheet" href="build/reset/reset.css">

                        <script type="text/javascript" src="build/yahoo/yahoo.js"></script>
                        <script type="text/javascript" src="build/event/event.js" ></script>
                        <script type="text/javascript" src="build/dom/dom.js" ></script>
                        <script type="text/javascript" src="build/dragdrop/dragdrop.js" ></script>
                        <script type="text/javascript" src="build/connection/connection.js" ></script>

                        <script type="text/javascript" src="build/container/container.js"></script>
                        <link type="text/css" rel="stylesheet" href="build/container/assets/container.css">
                       
                        <style>
                            body { background:#eee }
                            label { display:block;float:left;width:45%;clear:left; }
                            .clear { clear:both; }
                            #resp { font-family:courier;margin:10px;padding:5px;border:1px solid #ccc;background:#fff;}
                        </style>

                        <script>
                                YAHOO.namespace("test.container");

                                function init() {
                                   
                                    // Define various event handlers for Dialog
                                    var handleSubmit = function() {
                                        alert(this.getData().titleInfo());
                                        this.hide();
                                    };
                                    var handleCancel = function() {
                                        this.cancel ();
                                    };

                                    // Instantiate the Dialog
                                    YAHOO.test.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
                                    { width : "300px",
                                      fixedcenter : true,
                                      visible : false,
                                      modal : true,
                                      postmethod : 'manual',
                                      constraintoviewport : true,
                                      buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
                                                  { text:"Cancel", handler:handleCancel } ]
                                     } );
                                                       
                                    // Render the Dialog
                                    YAHOO.test.container.dialog1.render();

                                    YAHOO.util.Event.addListener("show", "click", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1, true);
                                    YAHOO.util.Event.addListener("resp", "dblclick", YAHOO.test.container.dialog1.show, YAHOO.test.container.dialog1 , true);
                                }

                                YAHOO.util.Event.addListener(window, "load", init);
                        </script>

                    </head>
                    <body>
                        <div>
                            <button id="show">Show dialog1</button>
                            <button id="hide">Hide dialog1</button>
                        </div>

                        <div id="dialog1">
                            <div class="hd">Please enter your information</div>
                            <div class="bd">
                                <form method="POST" action="../assets/post.php">
                                    <label for="textarea">Text area:</label><textarea name="titleInfo"></textarea>
                                </form>
                            </div>
                        </div>

                        <div id="resp">Server response will be displayed in this area</div>
                    </body>
                </html>

                On 12/12/06, Steven Peterson <y_stevenp@...> wrote:

                Martin,

                 

                This code looks right except for the missing parenthesis after "titleField". I tried it on my own and it works fine. Can you provide your full code so that I can see if something else may be causing your issue?

                 

                Thanks!

                 

                Steven Peterson

                Web Developer, Platform Engineering

                Yahoo!

                 

                 

                 

                From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Martin Tschofen
                Sent: Tuesday, December 12, 2006 2:51 PM
                To: ydn-javascript@yahoogroups.com
                Subject: [ydn-javascript] access form values from dialog handleSubmit

                 

                How can I access the form values in the success handler of a dialog?

                 

                I tried: 

                 

                var handleSubmit = function () {

                   alert(this.getData().titleField;

                   this.hide;

                }

                 

                titleField is defined inside a form inside the dialog:

                <textarea name="titleField"></textarea>

                 

                The dialog displays. After submitting I get "undefined".

                 

                I can access the data from within the validate function, perhaps I need to parse the elements in the dialog itself.

                 

                Thanks...martin

                 


                 

              Your message has been successfully submitted and would be delivered to recipients shortly.