7 Replies Latest reply: Feb 29, 2012 12:12 PM by Nancy O. RSS

    jquery help

    future-architect Community Member

      How would I make a call to a jquery function so that when a user submits a form, a image slowly fades in.  I am new to jquery, and all I can find is on button clicks.  would there be a way to call on the function, from php preferebly?

        • 1. Re: jquery help
          Ben Pleysier MVP

          future-architect wrote:

           

          How would I make a call to a jquery function so that when a user submits a form, a image slowly fades in.  I am new to jquery, and all I can find is on button clicks.  would there be a way to call on the function, from php preferebly?

          To answer the last part of your question first, jQuery is a JavaScript library. JavaScript is client side code that is interpreted by the browser. PHP is server side code which is interpreted by the server. With a few exceptions, because of the different platforms, the two cannot be interchanged. The exceptions include code that is executed by the server first like var myVar = <?php echo $myVar; ?>; and similar. Note that the document must have the PHP extension.

           

          For any action to occur, there must be an event that  triggers the action. You have already named the onclick event, but there are other events like onBlur, onChange, onLoad, onSubmit etc. that can be used as a trigger. These events can only be client side events.

           

          Gramps.

          • 2. Re: jquery help
            future-architect Community Member

            I was looking at these events, but I didn't see any that apply to my scenario.  here is what i was thinking....

             

            user submits form

            php picks it up, validates, and if the task is done successfully (i.e. updating fields in a db, sending an e-mail), calls on jquery to fade in the success image.

            • 3. Re: jquery help
              Ben Pleysier MVP

              Yes, that can be done.

               

              <?php

                   // if form submitted execute code to process the data

              ?>

                   // javascript to hide form and fade in image

              <?php

                   // end if

              ?>

              Gramps

              • 4. Re: jquery help
                future-architect Community Member

                sorry, new to javascript/jquery, and not sure how to fade in image/fade out form on the spot.  i can do it on a button click though! 

                 

                thought you had to do it in the head.  tried including <script> code b/w php tags, but it doesn't seem to work.  i thought you would be able to call the method, by doing something like this: echo ("<script>initImage();</script>");

                • 5. Re: jquery help
                  Nancy O. MVP

                  Put your success page url into the PHP script. 

                   

                  Then use jQuery on the success page.

                  http://alt-web.com/DEMOS/fading-logo-redirect.shtml

                   

                   

                  Nancy O.

                  Alt-Web Design & Publishing

                  Web | Graphics | Print | Media  Specialists 

                  http://alt-web.com/

                  http://twitter.com/altweb

                  • 6. Re: jquery help
                    future-architect Community Member

                    isn't there just a way for the image to slowly fade in without having to re-direct? 

                    • 7. Re: jquery help
                      Nancy O. MVP

                      Sure.  Simply remove the re-direct part.

                       

                       

                      Nancy O.

                      Alt-Web Design & Publishing

                      Web | Graphics | Print | Media  Specialists 

                      http://alt-web.com/

                      http://twitter.com/altweb