SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot kryptokid's Avatar
    Join Date
    Nov 2001
    Location
    Brisbane, Australia
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question onsubmit problem

    The problem:

    I have a survey form pop-up randomly when people enter the site. Once they have typed in the comment, they press "submit", the response is e-mailed to me and the pop-up window closes. The code I've used works perfetly in IE, but when using Netscape while it closes the window down, the users response doesn't get e-mailed to me.

    Anyone got any suggestions?

    Here's my code:

    <form method="post" action="http://mailgate.server-mail.com/cgi-bin/mailgate" onsubmit()=window.close()>
    <input type="hidden" name="recipient" value="daniel.wahry@det.qld.gov.au">
    <input type="hidden" name="subject" value="Survey Form">

    <p>
    <textarea name="textfield" rows="9" cols="32"></textarea>
    </p>
    <p align="center">
    <input type="submit" name="Submit" value="Send">
    <input type="button" onclick="window.close()" value="Close">
    </p>
    </form>

  2. #2
    SitePoint Addict ThomasAesir's Avatar
    Join Date
    May 2002
    Location
    Sydney, Australia
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Run your form submission from a function and call that function from your onsubmit like this:

    onsubmit()="submitme()"

    and the function:

    function submitme(){
    document.forms[0].submit();
    window.close();
    }



    I haven't tested it but it should work as long as your form is the first form on the page

    Oh and place the function in your header.
    Last edited by ThomasAesir; Jul 4, 2002 at 23:39.
    Thomas Oeser - Blueprint Software
    Web Scripting Editor v 5.2 One cool Web editing tool.
    3dcomputergraphics.com Coming Soon!

  3. #3
    SitePoint Zealot kryptokid's Avatar
    Join Date
    Nov 2001
    Location
    Brisbane, Australia
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok now the Response is e-mailed to me but the pop-up window doesn't close down. Why can't Netscape 4 play nice like all the other browsers?

  4. #4
    SitePoint Wizard Goof's Avatar
    Join Date
    Feb 2001
    Location
    Pittsburgh, PA
    Posts
    1,154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps I'm just ignorant, but shouldn't "onSubmit()" be "onSubmit"?

    Besides that, the window probably doesn't close because you're submitting the form first (which redirects the browser and possibly stops processing the script). Your best bet is to issue the window.close() statement on page returned by your CGI mailer. That way, the form will submit properly and the close command will be issued AFTER you're data has been properly mailed.

    Hope that helps,
    Goof
    Nathan Rutman
    A slightly offbeat creative.

  5. #5
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    KryptoKid, I've had a play with that URL (http://mailgate.server-mail.com/cgi-bin/mailgate) and it seems wide open to abuse - who runs it? Spammers (and others who want to bombard others with email) regularly trawl the 'net looking for scripts like this (although it's not as suitable for spamming as other scripts)......!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by M@rco
    and it seems wide open to abuse - who runs it? [/B]
    This is one of those perfect " You do! " moments.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •