SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2007
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setting up: "fill in email address and download"

    I need to set up a short form where the user fills in his email address, fills it in again (so they agree), it validates, and on the submit button being clicked, sends off the form results to an email account, but also a download file window pops up and begins downloading a file afer asking them where they want it saved.

    Anyone have any tips for this.
    thanks
    R

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by rickarooni View Post
    I need to set up a short form where the user fills in his email address, fills it in again (so they agree),
    Code html4strict:
    <form id="myForm" action="sendtoemail.php">
        <p><label>Email address <input type="text" name="email"></label></p>
        <p><label>Repeat email address <input type="text" name="email2"></label></p>
    </form>

    Quote Originally Posted by rickarooni View Post
    it validates, and on the submit button being clicked, sends off the form results to an email account, but also a download file window pops up
    Code javascript:
    document.getElementById('myForm').onsubmit = function () {
        var validates = validate(this);
        if (validates) {
            showDownload();
        }
        return validates;
    }
    function validate(form) {
        if (form.elements.email.value === form.elements.email2.value) {
            return true;
        } else {
            return false;
        }
    }

    Quote Originally Posted by rickarooni View Post
    and begins downloading a file afer asking them where they want it saved.
    Code javascript:
    function showDownload() {
        window.open('downloadFile.html', 'download', 'width=400,height=300,left=200,top=100');
    }

    Quote Originally Posted by rickarooni View Post
    Anyone have any tips for this.
    Not really, it's rather straight forward.
    Last edited by paul_wilkins; Aug 7, 2008 at 17:37.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2007
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    excellent! thank you so much.
    R


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •