Dark Mailer 2.0 Download

Dark Mailer 2.0 Download

Posted in:

How to Make a Slick Ajax Contact Form with j. Query and PHPStep 4 Include the j. Query library and set the delay. Our form is actually functional now. You can open the page in a browser, click the Send us an email link to jump to the form, fill in the fields, and submit the form to send the message. However, were now going to enhance our form using Java. Script to make the experience nicer for the user. Dark Mailer 2.0 Download' title='Dark Mailer 2.0 Download' />Well use j. Query to do most of the heavy lifting, so the first step is to include the j. Query library in the pages head element. Here weve linked directly to the j. Query library on Googles CDN, but you can download the library and host it on your own server if you prefer. Well also add a global config variable, message. Delay, to control how long the message boxes appear on the screen. This value is in milliseconds. Feel free to change it to a shorter or longer time. Delay 2. 00. 0 How long to display status messages in milliseconds. Step 5 Write the init function. The first stage of our form enhancing Java. Script is the init function. This sets up the form so that it can be shown and hidden on demand, and also modifies the form so that it will be submitted using our Java. Script, rather than sent natively by the browser. Heres the code. Init the form once the document is ready. Initialize the form. Hide the form initially. Make submit. Form the forms submit handler. Position the form so it sits in the centre of the browser window. Form. hide. submit submit. Form. add. Class positioned. When the Send us an email link is clicked. Fade the content out. Display the form. Move focus to the first field. Heres a secret for you when driving your traffic in, you let your prospects know that they can have some kickass free item if they only cover shippinghandling. Now out of prison but still disgraced by his peers, Gordon Gekko works his future soninlaw, an idealistic stock broker, when he sees an opportunity to take down a. Download the free trial version below to get started. Doubleclick the downloaded file to install the software. Prevent the link being followed. Form. click function. Dark Mailer 2.0 Download' title='Dark Mailer 2.0 Download' />To slow,. Form. fade. In slow, function. Name. focus. return false. When the Cancel button is clicked, close the form. Form. fade. Out. To slow, 1. When the Escape key is pressed, close the form. Form. keydown function event. Form. fade. Out. To slow, 1. Lets look at each chunk of the above code Init the form once the document is ready. We use the j. Query object,, to trigger our init function once the DOM is ready. Hide the form, set the submit handler, and position the form. The first thing we do inside the init function itself is make some changes to our form, contact. Form. First we hide it from the page using the j. Query hide method. Then we set its submit event handler to our submit. Form function which well write in a moment. This ensures that, when the user submits the form, submit. Form is called instead of the native browser form submission kicking in. Finally, we add the positioned CSS class to the form to reposition it in the centre of the browser window. Make the Send us an email links open the form. Next we bind an anonymous event handler function to the Send us an email links click events. This function fades out the page content so its only just visible in the background fades the contact form in and sets the focus on the Your Name field, ready for the user to start filling in the form. Finally, the function returns false to prevent the links from being followed. When the Cancel button is clicked, close the form. Now we bind another anonymous function to the Cancel buttons click event, so that the user can close the form by clicking the button. The function simply fades the form out, and fades the page content back in. When the Escape key is pressed, close the form. Similarly we bind a function to the contact forms keydown event, so that we can read any key the user presses when theyre viewing the form. In this function, we check if the user has pressed the Escape key character code 2. If they have then we close the form by fading it out, and fading the content in. Step 6 Write the submit. Form function. Weve now set up our form so that, rather than being submitted in the usual fashion, it will trigger the submit. Form function when the user submits it. This function needs to do some validation and, if all is well, submit the form data to the PHP script via Ajax. Heres the function in full. Submit the form via Ajax. Form. var contact. Form this. Are all the fields filled in Name. Email. val message. No display a warning message and return to the form. Message. fade. In. Delay. fade. Out. Form. fade. Out. Delay. In. Yes submit the form to the PHP script via Ajax. Message. fade. In. Form. fade. Out. Form. Form. attr method. Form. serialize. Finished. Prevent the default form submission occurring. Heres how the function works Store the contact form in a variable. Since well be using it a lot throughout the function, we start off by storing the contact form element in a contact. Form variable. This element is available to our function as the this variable, since the function is the event handler for the elements submit event. We wrap the element in a j. Query object to make it easier to work with. Check all the fields are filled in. Now we check that each fields value is not empty by using the j. Query val method on each field. Display a warning if the form isnt completed. If 1 or more of the fields are empty, we fade out the form, then fade in the incomplete. Messagediv, which contains the Please complete all the fields. We keep the message there for the time specified by the message. Delay variable, then fade it out again. Once its faded out, we fade the form back in so that the user can complete it. Submit the form if it is completed. Now we get to the meat of the Java. Script. If the form is completed then we first fade out the form, and fade in the Sending your message. Now we call the j. Query ajax method to submit the form via Ajax to the PHP script. We pass the following arguments to the method. Joe Weider Super Circuit Master Manual. The URL to send the form to. We grab this from the forms action attribute, and append an ajaxtrue parameter to the query string so that our PHP script knows the form was sent via Ajax, rather than via the usual method. The type of request to make POST or GET. We grab this from the forms method attribute, which in this case is set to POST. The data to send with the request. For this, we call the j. Query serialize method on the contact form object. This method takes all the field names and values in the form and encodes the data in a query string. We then pass this string to the ajax method so it can send the data to the PHP script. This is a callback function that will be called once the Ajax request has finished and the browser has received the response from the server. We set this to our submit. Finished function, which well write in a moment. Prevent the default form submission occurring. Finally, our event handler returns false to prevent the form being submitted in the usual way. Step 7 Write the submit. Finished function. The last function we need to write is submit. Finished, which is called once the Ajax response from the PHP script has been received by the browser. This function needs to check the response and display a success or error message as appropriate. Handle the Ajax response. Finished response. Message. fade. Out. Form submitted successfully. Display the success message. Clear the form fields. Fade the content back in. Message. fade. In. Delay. fade. Out. Name. val. Email. Delay5. 00. fade.