SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 28
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form on JavaScript

    Hi
    I need a JavaScript to make my form to be sent on e-mail. The problem is that than I click on "Send" i recieve a small .att file that only me and those who understand can read. This is the text:

    Nomen=Myname&Surname=Vitaalis&AnimalisNomine=Gavrus&Age=22&Urbus=Paris+%2F+France&Email=sdhfjs@gkjd.fjsi&Male=on&Textus=Exemple+of+the+textio+ieui+f&Mittere=%CE%F2%EF%F0%E0%E2%E8%F2%FC+%2F+Send

    In italic the text I fill in

    This is the HTML code

    <FORM name="Forma" method="post" action="mailto:historia@gavrus.com?subject=FabulaTua!" enctype="application/x-www-form-urlencoded" target="_self">

    Is that possible to make the text more lisible and how? but the form must be however sent on e-mail? Thank you.

  2. #2
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Consider the following:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function sendMail(_frm){
    var eml="you@youraddress.com";
    var bod="&body="+_frm.selOne.value+" "+_frm.txtOne.value;
    var subj="?subject=Whatever you want";
    document.location="mailto:"+eml+subj+bod;
    }
    </script>
    </head>
    <body>
    <form action="">
    <select name="selOne">
    <option value="Dog">Dog</option>
    <option value="Cat">Cat</option>
    </select>
    <textarea name="txtOne">
    </textarea>
    <input type="button" value="Submit" onclick="sendMail(this.form)" />
    </form>
    </body>
    </html>

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks
    I ve tried the script - it works! I'll try to generalize it (i have more than 100 items in the form, so i'll have to ), i think it's possible and I hope I'll be capable. If not - i'll ask another advise.

  4. #4
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bear in mind, you might want to call the function through an onclick event in a regular submit button. If the function returns the Boolean false, the submit will not take place. If JavaScript is disabled, the regular submit method will proceed.

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, Two more problems :
    1) After having filled in the form the user can change everything he's written im the text of the mail
    2) I can't make new lines in the text of the mail : if I write in the script
    ... +_frm.selOne.value+ " <br> " + _frm.txtOne.value
    I have
    dog <br> text in the mail

    If i write
    ... +_frm.selOne.value+ " \n " + _frm.txtOne.value
    I have just
    dog text in the mail

    No new line!
    Any suggestions?

  6. #6
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another problem:
    The <input type="radio"> with the same name and different values don't work:

    <input type=radio name="Radio" value="Yes">
    <input type=radio name="Radio" value="No">
    in the code give

    Radio undefined in the mail. But it worked correctly in my previous code (with the crazy .att file). REALLY NEED HELP!

  7. #7
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The values of radio buttons are passed as an array. You must loop through the array and find the value for which checked is true.

    While Mozilla will recognize <br />, Outlook Express will not. The only solution I have found is to insert a non-standard character, like the pipe symbol, then process the email upon receipt, replacing the symbol with crlf's.

  8. #8
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Finally i've find the solution
    <form action="mailto:name@domain.com" method=POST enctype="text/plain">
    The received mail looks like this:
    name=value
    name=value
    name=value etc

    with new lines as i wanted.
    Another question: when i submit the form, the page is refreshed and i have the same form. Is the possible to make open another page (confirmation page or something of the kind) instead?

  9. #9
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good find! Note that older browsers used the attribute name "encoding". You can also have "text/html", for what it's worth.

    Client-side, I don't believe there is any event that confirms the form's having been sent. Actual confirmation of receipt would have to originate at the server.

    To produce a confirmation popup that would be reasonably reliable, though not 100%, you could call a function that would display the confirmation message using setTimeout() to delay its appearance. You would call the function with onsubmit and have it return true. Upon the return of true by the function, the submission would proceed normally. Meanwhile the setTimeout() timer would wait, then display the confirmation message.

  10. #10
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another problem. After submission from my computer onto my email everything is ok: normal mail with normal text and message subject. But from my client's computer i recieve a message with normal subject but without anything inside: just a blank body. Is that normal? Can that depend of the used browser? Are there any particularities of using <form> tags in Netscape and IExplorer or in different versions of the same browsers?

    As for the confirmation page: as far as i understandthe pop up will not result from verification of sending of the mail or not, but from the javaScript function that will start every time i call it (even if in the reality the mail is faild)?

    PS. Sorry for my English. Hope u understand me

  11. #11
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are right, there is (to the best of my knowledge) no way to determine from JavaScript that a message has actually been sent. Once the form action takes over, either to send the form to a server or to the e-mail client program, I'm pretty sure it's out of JavaScript's domain. On the other hand, the user still has to hit the send button and should get confirmation from their e-mail program that the e-mail was sent.

    As for the blank message, I'm afraid the only way around it may be the aformentioned JavaScript technique. Internet Explorer doesn't seem to want to cooperate with the mailto action. You might want to use the JS function for IE, and return false to stop the regular submission. With other browsers you could have the function skip through to the regular submit method, with a return of true.

  12. #12
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Me again. I'm getting crazy with this f***ing form!
    Is that possible that when the submit button is clicked on the client's computer, he's got a message window as in your JavaScript sendMail function (or when u click on a mailto: link) but with NO message in the body, although there's NO such a function in my script any more?

  13. #13
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you mean, will the mailto action proceed from a submit button with an onclick value that calls a nonexistent function, or a form with a nonexistent onsubmit function, yes. The mailto will proceed unless false is returned by the function.

  14. #14
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No! This is the code:
    <form name="Forma" method="post" enctype="text/plain" action='mailto:name@domainname.com?subject=heurfdufhwudyf'>
    <input type="submit" value="valider" name="Valider">
    </form>
    No JavaScript function in submit. Only verifying onBlur in <input>s. Some clients' computers send me correct form, others - empty message with correct subject.

  15. #15
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Internet Explorer, at least in version 6, doesn't put the form body into the message body when using the mailto: action. In order for message body contents to transfer from that browser to its mail client (Outlook), they must be included in the mailto: action with &body=. This means you either need to know what you want in the body before hand, or use JavaScript.

  16. #16
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But it works from my computer and almost from all others. When submitting the form I have "This form will be send by email and will alow your adressee to see your email. Do u want to continue or cancel?" I click OK, another small message "a program try to send the following message to (adressee'email, empty) Subject (Demande de Devis, as it must be). Do u want to send the message? Send. Concel" . I click "send" , the form is send and i even dont see the body. In two seconds I receive the mail with filled in the body. There r only one or two of them which open a "write a new message" window and make u write the message all by yourself.
    Here's the page URL http://www.rouslan-demenagement.com/Paginae/Forma.htm
    Try to send the empty form ("valider" as submit button), just put "Proba2" in the NOM (name) field. U'll see yourself.

  17. #17
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In IE6 on WinXP I get no body contents. On Moz 1.5 the contents appear.
    Peut-etre c'est une probleme d'WinXP.
    Last edited by JVLB; Jul 10, 2004 at 19:22.

  18. #18
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When u say "no body contents on WinXP" do u mean you send the form without any problems or you have the "new mail" window and u have to fill it? The computers I'm talking about run exactly under WinXP. But a friend of mine sent the form from XPpro with no problem. What can I do about it?

  19. #19
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for answering me. Stupid problem.
    Bravo pour ton francais

  20. #20
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I mean the body of the e-mail created in Outlook Express is blank, no contents at all. Mozilla, on the other hand, has the "Raison sociale=Mme Nom=Proba2 Prenom= Telephone= Portable= Telephone Professionnel= Fax= Email= Date de~" etc. in the body.

    I am using IE 6 on WinXP Pro to test (Moz 1.5 is my regular browser).

    A kind of off the wall question occurs, does your friend's machine have the Cyrillic character set installed? I can't imagine why that might affect this, but given your other interesting situation, I wonder if there is a connection. (I don't have the Cyrillic installed.)

  21. #21
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The person who cant send the form has XP home IE6 and she s got the blank body like you. The other, who sent the form normally has XPpro IE6. I have win2000 pro. No problems neither. The two has Cyrillic installed, me two (we r all Russian ). No problem with mozilla, I ve got the same body when I settle hotmail as default mail program

  22. #22
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think it may be because of cyrillic. May be security settings?

  23. #23
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I don't think it's the Cyrillic either. I suppose it could be security, but that doesn't make a lot of sense since the most sensitive thing is the sender's mailto address and after the initial warning, it happily puts that in the e-mail. I have scripting enabled (though I have unsigned ActiveX controls disabled, but ActiveX shouldn't be involved here) and "Submit nonencrypted form data" enabled. I do get the same result running a simple test form locally, on my computer. (By the way, you might find it amusing to note that Vitalis is a hair-dressing in the U.S.)

  24. #24
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Paris
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to change the security options of Outlook Express enabling "encrypt the content and joined files of all coming out messages". No changes - my form is sent as before, without any problems.
    Any way, one thing is sure - it is not my script's or HTML's flaw, but clients' system settings. Hope I'm right
    PS. If this is a famous and big hair-dressing I'm not against them to borrow my name

  25. #25
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a link to a Microsoft article on the phenomenon in question: http://support.microsoft.com/default...b;en-us;154864

    Although it doesn't list IE 6, it does create some questions about using mailto with IE. You might also like to see Microsoft's recommended use of mailto, about 2/3 of the way down the page at "Submitting Forms": http://msdn.microsoft.com/workshop/author/forms/formsoverview.asp

    Given the description of the problem at the first URL, I wonder if the behaviour is exhibited in IE 6 when Outlook Express isn't the default mail application. IE 6 still calls OE, obviously, but on my system, for instance, it is not the default mail app, Mozilla is.


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
  •