e-mail code in javascript of HTML

Status
Niet open voor verdere reacties.

danny123

Gebruiker
Lid geworden
15 okt 2007
Berichten
71
hallo,
ik weet het dat heel helpmij.nl vol staat met zo'n soort vragen maar het goede antwoord kan ik niet vinden.

daarom :

ik heb een e-mail script nodig voor in Frontpage dus HTML of javascript niet anders!

bij een formulier waarin : onderwerp , tekst en afzender moet staan

als je op verzenden klikt moet alle ingevulde tekst gestuurd worden naar een e-mail adres.


ps : het moet in frontpage, het moet in html of javascript


alvast heel erg bedankt !!!!
 
Hoi danny123,

Deze is vrij gemakkelijk aan te passen.

Javascript gedeelte:
PHP:
  <SCRIPT language="JavaScript">
  <!-- Hide from older browsers

  // Original JavaScript code by Duncan Crombie: dcrombie@chirp.com.au
  // Please acknowledge use of this code by including this header.

  function mailIt() {
    var dataForm = document.dataForm; // visible form
    var mailForm = document.mailForm; // hidden form
    var message = dataForm.body.value;
    
// redefine the mailForm action property
    mailForm.action = "mailto:" + dataForm.recipient.value;
    mailForm.action += "?subject=" + dataForm.subject.value;
    
// retrieve location information
    var pageTitle = "Page Title: " + document.title;
    var sentFrom = "Mailed From: " + document.location;
    var userInfo = pageTitle + "\r\n" + sentFrom + "\r\n\r\n";
    
// transfer all information from dataForm to mailForm for sending
    mailForm.mailBody.value = userInfo + message;
    
// open new window
    newWindow = window.open("", "new_Window", "status='yes', scrollbars='yes'");
    newWindow.document.clear();
    
// create a page that presents the transmitted message
    newWindow.document.write("<HTML><HEAD><TITLE>Message sent to " + dataForm.recipient.value + "</TITLE></HEAD>");
    newWindow.document.write("<BLOCKQUOTE>");
    newWindow.document.write("<BODY bgcolor='white'>");
    newWindow.document.write("<H2>The following message has been sent:</H2>");
    newWindow.document.write("Recipient: " + dataForm.recipient.value + "<p><hr><p>");
    newWindow.document.write(message + "<p>");
    newWindow.document.write("<hr><p><DIV align='right'><FORM>");
    newWindow.document.write("<INPUT type='button' value=' Close Window ' onClick='window.close();'>");
    newWindow.document.write("</FORM></DIV></BLOCKQUOTE></BODY></HTML>");
    newWindow.document.close();
    
// return true to send mail (returning false should prevent submission)
    return true;
  }

// Stop hiding -->
</SCRIPT>


In je site kun je dan zoiets doen:

PHP:
  <table>
    <FORM name="dataForm" method="post">
      <font color="#FFFFFF">
      <!-- The first form is the one that appears on the page -->
      </font>
      <TR> 
        <TH align="right"><font color="#FFFFFF">Send Message To: </font></TH>
        <TD><font color="#FFFFFF">
          <INPUT name="recipient" size="50" value="ontvanger@nospam.com">
          </font></TD>
      </TR>
      <TR> 
        <TH align="right"><font color="#FFFFFF">Subject: </font></TH>
        <TD><font color="#FFFFFF">
          <INPUT name="subject" size="50" value="Onderwerp:">
          </font></TD>
      </TR>
      <TR> 
        <TH align="right" valign="top"><font color="#FFFFFF">Body: </font></TH>
        <TD><font color="#FFFFFF">
          <TEXTAREA name="body" cols="50" rows="10" wrap="virtual">

          </TEXTAREA>
          </font></TD>
      </TR>
    </FORM>
    <FORM name="mailForm" action="mailto:" method="post" enctype="text/plain" onSubmit="return mailIt();">
      <font color="#FFFFFF">
      <!-- The contents of this field are filled out when the submit button is pressed -->
      <INPUT type="hidden" name="mailBody" value="">
      </font>
      <TR> 
        <TD>&nbsp;</TD>
        <TD align="right"><font color="#FFFFFF">
          <INPUT type="submit" value="Send Message Now" onClick="return(confirm('Send this message to ' + document.dataForm.recipient.value))";>
          </font></TD>
      </TR>
    </FORM>
   </table>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan