SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Aug 2004
    Location
    USA
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    1 Submit Button -2 actions

    Okay, so I've been trying to do this in DW. It works in Safari but not in IE. I'm trying to get a user to submit their name and eMail address when they click the submit button and then be taken to a new page. In Safari, both these things happen (however, their email proram pops up with the submitted data, but they don't have to submit it- the new page still loads).
    In IE, the email is automatically sent, but the new window doesn't open.
    Here is the code;
    in the head-
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    }

    in the body-
    <form action="mailtoam@cape.com" method="post"
    enctype="text/plain" name="MLS" id="MLS">

    <input type="text" name="name" value=" " size="40" /></p>

    <input type="text" name="email" value=" " size="40" />

    <input name="submit" type="submit" id="submit"
    onClick=MM_goToURL('parent','frameset.htm');

    Any help will be greatly appreciated as I'm about to pull out the last of my hair.1 Submit Button -2 actions

  2. #2
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Rochester, NY
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Honestly...

    ...I wouldn't use javascript for this, I'd use PHP. It's more secure and will work on everyone's browser. I'm sorry I can't help you more than that, but check out Kevin Yank's "Advanced E-mail" article, it'll tell you everything that you need to know.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I can tell, javascript doesn't have any mailing capabilities. A 'mailto' url is basic html, and when I try it with IE6, the email does not get sent automatically(I think that would be a security issue if it did). I think earlier browsers might have allowed it, but since it was a security problem that allowed a web site to silently harvest emails from visitors, it was plugged up.

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm trying to get a user to submit their name and eMail address when they click the submit button and then be taken to a new page.
    Reading your question again, it seems you may have a form where the user fills out their name and email address and then clicks on the submit button. Since you want to submit the data to the server, the page listed in the action attribute:

    <form action="..."

    will process the data on the server side, and presumably record the data in your database, and then send some new content to the browser. Where does javascript come into play?

  5. #5
    SitePoint Member
    Join Date
    Aug 2004
    Location
    USA
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 7stud
    Reading your question again, it seems you may have a form where the user fills out their name and email address and then clicks on the submit button. Since you want to submit the data to the server, the page listed in the action attribute:

    <form action="..."

    will process the data on the server side, and presumably record the data in your database, and then send some new content to the browser. Where does javascript come into play?
    Actually, I want the info emailed to me. I'm not sure if i'm explaining this right, but when the user hits the submit button, I want their info emailed to me and have them taken to a new page.

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On Firefox1.0 and IE6 this won't email you automatically(I don't think any modern browser will let you do that, for the security reasons I stated earlier), but this will direct you to a new page:

    Code:
    <!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    
    <html xmlns="http://www.w3.org/1999/xhtml" 
      xml:lang="en" lang="en">
    
    <head>
    <title>html and javascript</title>
    <script type="text/javascript" language="javascript">
    <!-- Hide from browsers lacking javascript
    
    window.onload=function()
    {
    	document.getElementById("send").onclick=function(){location.href='another_page.htm';};
    };
    
    // End hiding -->
    </script>
    </head>
    
    <body>
    <form name="f" method="post" action="mailto: you@yourdmainhere;">
    <input type="submit" id="send" value="send" />
    </form>
    
    </body>
    </html>


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
  •