There is a site on Narod.ru. The site has a page Orders where the order of services to perform work. There is a form to fill in the order (fields - email - who ordered, name - order subject, zakaz - order text itself, what you need). You need to implement the contents of the completed forms by email.

I tried a bunch of scripts, but nothing happened ... Yandex opens the page for creating a new letter, and inserts all the information entered into the form into the "To" line ... Although in theory, by clicking the send button, the user's mail program should open and letter fields "To", "Subject", "Message", should be automatically filled with data ...

How to implement it in reality? Those. right) Thank you.

<FORM NAME="mailer" METHOD="post" ENCTYPE="text/plain" onSubmit="(document.mailer.action += mailtoandSubject)"> Email:<br> <INPUT TYPE="text" NAME="email" size="24" onChange="msg (this.form)"><br> Тема или название работы:<br> <INPUT TYPE="text" NAME="Subject" size="24" onChange="msg (this.form)"><br> Текст задания:<br> <TEXTAREA NAME="zadanie" COLS="40" ROWS="6" onChange="msg (this.form)"> </TEXTAREA> <br> <INPUT TYPE="submit" VALUE="Отправить" ONCLICK="return checkIt ()"> <INPUT TYPE="reset" VALUE="Сброс"> </FORM> <SCRIPT LANGUAGE="JavaScript"> function checkIt () { if (document.forms.mailer.email.value!= "") { } else { alert ("Пожалуйста, введите свой Email."); document.forms.mailer.email.focus (); return false; } if (document.forms.mailer.Subject.value!= "") { } else { alert ("Пожалуйста, введите название или тему работы:"); document.forms.mailer.Subject.focus (); return false; } if (document.forms.mailer.zadanie.value!= "") { return true; } else { alert ("Пожалуйста, напишите задание работы."); document.forms.mailer.zadanie.focus (); return false; } } function msg () { document.mailer.action = "mailto:Leshij-2005@yandex.ru" mailtoandSubject = (('?Subject=' + document.mailer.Subject.value) + '&Body=' + document.mailer.zadanie.value); } </SCRIPT> 

What is wrong here? ...

  • Is php supported by the people? - oleg_ismaylov
  • The people are not ... Toka Js ... Damn it that the whole thing is in the POST method? - Leshij_2005 2:21 pm
  • And for mailto: do not need php) is a function call on the client. processed for example by outlook. - Sh4dow pm
  • one
    @ Leshij_2005 it's not about the POST method, but about the fact that on your computer to handle links mailto: Yandex.mail is installed. For other users, everything will work =) And I would advise you to put the client in the mail, but this is a matter of taste. There will be a lot of letters - rate) - Sh4dow
  • 2
    @ Leshij_2005 for this, you will need to manually create a URL for each email service you want to support (try to analyze the address lines when composing letters in them or google it). But this way a) is fraught with errors (on the hashcode somehow there was a question with GMail and Standard View, I don’t remember if we decided it), b) is intrusive for the user. Using mailto: is, in my opinion, the accepted standard. - yozh pm

3 answers 3

A lot of superfluous.

Remove onsubmit. onChange = "msg (this.form)" can be replaced by onChange = "msg ()". The mailtoandSubject variable is not declared as global. IMHO, it is not needed at all. Enter id (Form: id = "mailer", Subject: id = "mailer-subject", zadanie: id = "mailer-zadanie")

 function msg () { document.getElementById('mailer').action = "mailto:Leshij-2005@yandex.ru" + '?Subject=' + document.getElementById('mailer-subject').value + '&Body=' + document.getElementById('mailer-zadanie').value; return false; } 

UPD : here you have a 100% working code) Adapt, I hope - only id replace

 <html><head></head><body> <script type="text/javascript"> function msg1() { document.getElementById('f1').action = 'mailto:Leshij-2005@yandex.ru' + '?subject='+encodeURIComponent(document.getElementById('i1').value) + '&body='+encodeURIComponent(document.getElementById('i2').value); alert(document.getElementById('f1').action); return false; } </script> <form method="post" action="" id="f1"> <input id="i1" onchange="msg1()" value="" /> <input id="i2" onchange="msg1()" value="" /> <input type="submit" value="ok" /> </form> </body> </html> 

PS: 'Subject'! = 'Subject', 'Body'! = 'Body'

  • I tried using id, but the result is the same ... Everything is in one line "To" ... - Leshij_2005
  • Watch the update - Sh4dow
  • Alas, but the same) All infa in one line "To" .. Most likely it is a matter of the Yandex system itself .. - Leshij_2005
  • Yandex? hmmm, you, it seems, were defaulted for processing)) It is better not to do this. I don’t know which encoding is on the people, but I suspect sr1251, most likely, this is a transfer glitch to Unicode Yandex.mail. Outlook / Firebird accepts without problems. - Sh4dow
  • @ Sh4dow, are you sure that everything will work fine with mailto ?? as my example shows, where my default email client is Yandex, nothing works .. And I am not the only one .. So this should also be taken into account ... - Leshij_2005

As a result, it is easier and more convenient than all, as it seems to me, to write a program for the client to complete the work order, and on the website a link for downloading and a detailed description ... And everything will be fine at once, i.e. everything will refer to one place and the information will have the right look ... Otherwise, switch to a "good" host and create there with all available means ...

  • Executor No one will not download. Hosting with PHP can be found for fifty dollars a month. (And if you are not confused by the reputation of narod.ru, then there are free). Ready-made feedback scripts - tuyeva hucha) I don’t understand why you need so much crap, I dealt with this issue only from sports interest) - Sh4dow
  • Yes, I just need my feedback, with my input fields, there are about 7 of them according to the idea .. And then after entering, they should be formatted and sent to email ... And these scripts do not work as expected, take the example above, the information is not necessary way it is inserted into the fields of the mail client, whatever it is (Yandex, Mail? Google, The Bat, etc.) ... - Leshij_2005
  • 1stwebdesigner.com/tutorials/custom-php-contact-forms + 000webhost.com/free-php-hosting It was found in a minute of googling) And the people. Ru died a long time ago. - Sh4dow
  • Thanks for the info ... We will try ... I’m bad with English, so I’m looking at the current Russian-speaking sources .. People? Well, you can say that, but you can make a business card for yourself there) - Leshij_2005

Not exactly the answer to the question. But to send a mail form from a static page, you can use third-party services like this .