Link to home
Start Free TrialLog in
Avatar of senthil021397
senthil021397

asked on

Dynamic mailing

Is it possible to have a email column in a fill in web form and when the user hits the 'SUBMIT' the contents of the form should be mailed to this filled out email-id. IS IT POSSIBLE TO DO THIS USING JAVASCRIPT
ASKER CERTIFIED SOLUTION
Avatar of jshamlin
jshamlin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of senthil021397
senthil021397

ASKER

Thanks for the solution. Had one more question, When the user hits 'Submit', after mailing the contents i want to load a 'Thank you' page. Tried to do this with no success, can you help me in this. Have enclosed the code

**********************
<HTML>

<HEAD><TITLE>MSP Systems Feedback Form</TITLE>

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
<!--

function mailIt(form) {
  var data = document.dataForm
  var userInfo = ""
  form.action += "?subject=" + data.subject.value
  userInfo += "Page Title:  " + document.title + "\n"
  userInfo += "Mailed From: " + document.location + "\n\n"
  form.mailBody.value = userInfo + data.body.value
}
// -->
</SCRIPT>



</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT=navy LINK=red VLINK=red>

<center><IMG SRC="/OWS-IMG/logointl.gif" ALIGN="BOTTOM" ALT="Texas Instruments" width=600 height=33><br></center>

<center><nobr><A HREF="http://www.ti.com/sc/docs/schome.htm"><IMG SRC="/OWS-IMG/scnv1.gif" ALT="Semiconductors" border=0></a><A HREF="http://www.ti.com/sc/docs/msp/msphome.htm"><IMG SRC="/OWS-IMG/scnvmsp.gif" ALT="Mixed Signal and Analog" border=0></A><A HREF="http://www.ti.com/sc/docs/search.htm"><IMG SRC="/OWS-IMG/mpsernav.gif"  border=0 ALT="Search"></A><IMG SRC="/OWS-IMG/feednav.gif"  border=0 ALT="Feedback"><A HREF="http://www.ti.com"><IMG SRC="/OWS-IMG/tihmnav.gif"  border=0 ALT="TI"></A></nobr><BR></center>

<center>
<TABLE BORDER=3 CELLSPACING=5  width=600>
<tr>
<th><a href="/msp/product/pdbspec.html"><FONT COLOR="black">PDB SPEC PAGE</a></th>
<th><a href="/msp/product/ptssspec.html"><FONT COLOR="black">PTSS SPEC PAGE</a></th>
</tr>
</TABLE>
</center>
<CENTER>

<TABLE>

<FORM NAME="dataForm">

<TR><TH ALIGN=right>Name: <TD><INPUT NAME="name" SIZE=40 > </TR>
<TR><TH ALIGN=right>Subject: <TD><INPUT NAME="subject" SIZE=40></TR>
<TR><TH ALIGN=right VALIGN=top>Message:<TD><TEXTAREA NAME="body" COLS=60 ROWS=10 WRAP=virtual></TEXTAREA></TR>

</FORM>

<FORM
  NAME="mailForm"
  ACTION="mailto:senthil@ti.com?subject=Feedback from SPEC/370 WEB FORM"
  METHOD="post"
  ENCTYPE="multipart/form-data"
  onSubmit="return mailIt(this)">

<INPUT TYPE="hidden" NAME="mailBody" VALUE="">
<TR><TD COLSPAN=2 ALIGN=center><INPUT TYPE="submit" VALUE="Send This Mail Message Now"></TR>
</FORM>
</TABLE>

<p>
<p>

<center><nobr><A HREF="http://www.ti.com/sc/docs/schome.htm"><IMG SRC="/OWS-IMG/scnv1.gif" ALT="Semiconductors" border=0></a><A HREF="http://www.ti.com/sc/docs/msp/msphome.htm"><IMG SRC="/OWS-IMG/scnvmsp.gif" ALT="Mixed Signal and Analog" border=0></A><A HREF="http://www.ti.com/sc/docs/search.htm"><IMG SRC="/OWS-IMG/mpsernav.gif"  border=0 ALT="Search"></A><A HREF="/sc/docs/feedback.htm"><IMG SRC="/OWS-IMG/feednav.gif"  border=0 ALT="Feedback"></A><A HREF="http://www.ti.com/corp/docs/home.htm"><IMG SRC="/OWS-IMG/tihmnav.gif"  border=0 ALT="TI Home"></A></nobr><BR></center>
<ADDRESS>
<CENTER>

<A HREF="http://www.ti.com/corp/docs/copyrght.htm">(c) Copyright</A> 1997 Texas Instruments Incorporated. All rights reserved. <BR>



<p>
<center><IMG SRC="/OWS-IMG/owsdr.gif"></center>



</CENTER>

</ADDRESS>


<CENTER>
<script language="JavaScript">
<!--
      document.write("Updated " + document.lastModified);
// -->
</script>

</CENTER>
</BODY>
</HTML>
Addint a "thanks" page is pretty simple - just makethe last line of code in your mailIt() something like this ...

document.loaction = 'thankspage.html';

A static HTML page (thankspage.html) will generally suffice.
Per your advice, changed the function like this and still doesn't seem to work. Any suggestions..

***********
<SCRIPT LANGUAGE="JavaScript">
<!--

function mailIt(form) {
  var data = document.dataForm
  var userInfo = ""
  form.action += "?subject=" + data.subject.value
  userInfo += "Page Title:  " + document.title + "\n"
  userInfo += "Mailed From: " + document.location + "\n\n"
  form.mailBody.value = userInfo + data.body.value
  document.location = 'http://msp03.msp.sc.ti.com';
  return true
}
// -->
</SCRIPT>
Sorry ... overlooked the problem with the existing script (the document.location should load a new page when the rest of it works).

One note: this no longer looks like it's being mailed dynamically (to an e-mail address selected by the user via a form element) - looks like a plain ol' mailto: form - for that, you could skip the JavaScript altogether.  

Try the following HTML code on a "test" page and let me know how the results you get from this code differ from that which you'd like to get via a javascript-enhanced version:

<HTML><HEAD><TITLE>Test Feedback Form</TITLE>
<FORM NAME="mailForm" METHOD="post" ACTION="mailto:senthil@ti.com?subject=Feedback from SPEC/370 WEB FORM" ENCTYPE="multipart/form-data">
<PRE>
   Name:  <INPUT NAME="name" SIZE=40 >
Subject:  <INPUT NAME="subject" SIZE=40>
Message: <TEXTAREA NAME="body" COLS=60 ROWS=10 WRAP=virtual></TEXTAREA>
<INPUT TYPE="SUBMIT" VALUE="Send This Mail Message" onClick="this.location='http://msp03.msp.sc.ti.com'">
</PRE></FORM></BODY></HTML>



Actually i am on the one who misled you, I am trying to show a 'THANKS' page when the user hits Submit on the following code. This is the code which collects the user's email id from the form element and emails the contents to user.

Sorry for the inconvenience
********************************

<HTML>
<HEAD>
<title>SPEC/370 PDB Requirements</title>

<SCRIPT LANGUAGE="JavaScript">

function response()

      {
         location.href="http://msp03.msp.sc.ti.com/msp/product/pdbspec.html";
      }

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
<!--

/*  Author's Name:        Senthil Velayudham
    Department   :        MSP Operations
*/        
function mailIt(form) {
  var data = document.dataForm
  var userInfo = ""
  var dataInfo = ""

  form.action += data.recipient.value + "," + data.recipient1.value

  userInfo += "Page Title:  " + document.title + "\n"
  userInfo += "Mailed From: " + document.location + "\n\n"
  dataInfo += "Device Name: " + data.Device.value + "\n\n"
  dataInfo += "Similair Device: " + data.SDevice.value + "\n\n"
  dataInfo += "Description: " + data.DESC.value + "\n\n"
  dataInfo += "DIE NAME: " + data.DIENAME.value + "\n\n"
  dataInfo += "FAB CODE: " + data.FABCODE.value + "\n\n"
  dataInfo += "STD PKG QTY (tube): " + data.tube.value + "\n\n"
  dataInfo += "STD PKG QTY (tray): " + data.tray.value + "\n\n"
  dataInfo += "STD PKG QTY (reel): " + data.reel.value + "\n\n"
  dataInfo += "ASSEMBLY: " + data.ASSEMBLY.value + "\n\n"
  dataInfo += "TEST: " + data.TEST.value + "\n\n"
  dataInfo += "A/T :  " + data.ASSTEST.value + "\n\n"
  dataInfo += "TECH :  " + data.TECH.value + "\n\n"
  dataInfo += "PRODFAM :  " + data.PRODFAM.value + "\n\n"
  dataInfo += "FUNCTION :  " + data.FUNCTION.value + "\n\n"
  dataInfo += "EXTFUNC :  " + data.EXTFUNC.value + "\n\n"
  dataInfo += "PERFORM:  " + data.PERFORM.value + "\n\n"
  dataInfo += "PIN :  " + data.PIN.value + "\n\n"
  dataInfo += "PACKAGE :  " + data.PACKAGE.value + "\n\n"
  dataInfo += "RELCLASS :  " + data.RELCLASS.value + "\n\n"
  form.mailBody.value = userInfo + dataInfo + data.body.value
  return true
}

// -->
</SCRIPT>

</HEAD>

<BODY bgcolor="#FFFFFF" text="#000000">

<center>
<!--TI LOGO START-->


<IMG SRC="/OWS-IMG/logointl.gif" ALIGN="BOTTOM" ALT="Texas Instruments" width=600 height=33><br></center>


<!--TI LOGO END-->


<!--SC MSP NAV BAR START-->

<center><nobr><IMG SRC="/OWS-IMG/blknavb.gif" WIDTH=300 HEIGHT=22 border=0><A HREF="http://www.msp.sc.ti.com"><IMG SRC="/OWS-IMG/scnvmsp.gif" ALT="Mixed Signal and Analog" border=0></A><A HREF="http://www.ti.com/sc/docs/search.htm"><IMG SRC="/OWS-IMG/mpsernav.gif"  border=0 ALT="Search"></A><A HREF="/msp/product/feedback.html"><IMG SRC="/OWS-IMG/feednav.gif"  border=0 ALT="Feedback"></A><A HREF="http://www.ti.com"><IMG SRC="/OWS-IMG/tihmnav.gif"  border=0 ALT="TI"></A></nobr><BR></center>

<!--SC MSP NAV BAR END-->

<center>
<h3> SCU-MSP NEW DEVICE SETUP/CHANGES</h3>
<p>
<h4> PDB REQUIREMENTS</h4>
</center>


<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<FORM NAME="dataForm">

<TR><td ALIGN=left>DEVICE NAME</td><td><INPUT NAME="Device" SIZE=40 VALUE="" ></td> </TR>
<TR><td ALIGN=left>SIMILAR DEVICE</td><td><INPUT NAME="SDevice" SIZE=40 ></td> </TR>
<TR><td ALIGN=left>DESCRIPTION</td><td><INPUT NAME="DESC" SIZE=40 ></td> </TR>
</table>
</center>
<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<TR><TD>DIE NAME</td><TD><INPUT NAME="DIENAME" SIZE=20"></td>
<TD>FAB CODE</th><TD><INPUT NAME="FABCODE" SIZE=20"></td></TR>
<TR bgcolor=orange><TD>Planner Email ID</td><TD><INPUT NAME="recipient" SIZE=20 VALUE="senthil@ti.com"></td>
<TD>REQUESTOR Email ID</td><TD><INPUT NAME="recipient1" SIZE=20 VALUE="senthil@csc.ti.com"></td></TR>
</table>
</center>

<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<TR><TD width=25%><a href="http://www.shvp.sc.ti.com/aslpkg/SLLP/database.html">STD PKG QTY (tube)</a></TD><TD  width=25%><INPUT NAME="tube"></TD>
<TD  width=25%><a href="http://www.shvp.sc.ti.com/aslpkg/SLLP/database.html">STD PKG QTY (tray)</a></TD><td width=25%><INPUT NAME="tray"></TD></TR>
<TR><TD><a href="http://www.shvp.sc.ti.com/aslpkg/SLLP/database.html">STD PKG QTY (reel)</a></TD><td><INPUT NAME="reel"></TD></tr>
</table>
</center>

<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<tr><td width=24%>ECCN EXPORT CODE </TD><td><INPUT NAME="ECCN EXPORT CODE      " SIZE=20 ><br>NOTE: See QSS 007 003; Typically EAR99</td></tr>
</table>
</center>
<p>
<p>
<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<tr><td>
<B>BESIDE THE APPROPRIATE FCC/LBE SITE, SELECT (A) FOR ASSEMBLY (ONLY), (T) FOR TEST (ONLY) OR (A/T) FOR ASSEMBLY & TEST</B>
</TD></TR>
</TABLE>
</CENTER>

<center>
<P><P>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<TR>
<TD>ASSEMBLY (A)</TD>
<td><SELECT NAME="ASSEMBLY">
<OPTION>ANA<OPTION>AP3<OPTION>ASAT<OPTION>FMX<OPTION>HIJ<OPTION>LEN
<OPTION>MLA<OPTION>PHI<OPTION>POR<OPTION>SFAM<OPTION>SSS<OPTION>TAI
<OPTION>TIK<OPTION>AP3<OPTION>ASAT</select></td>

<TD>TEST (T)</TD>
<td><SELECT NAME="TEST">
<OPTION>ANA<OPTION>AP3<OPTION>ASAT<OPTION>FMX<OPTION>HIJ<OPTION>LEN
<OPTION>MLA<OPTION>PHI<OPTION>POR<OPTION>SFAM<OPTION>SSS<OPTION>TAI
<OPTION>TIK<OPTION>AP3<OPTION>ASAT</select></td>

<TD>ASSEMBLY & TEST (A/T)</TD>
<td><SELECT NAME="ASSTEST">
<OPTION>ANA<OPTION>AP3<OPTION>ASAT<OPTION>FMX<OPTION>HIJ<OPTION>LEN
<OPTION>MLA<OPTION>PHI<OPTION>POR<OPTION>SFAM<OPTION>SSS<OPTION>TAI
<OPTION>TIK<OPTION>AP3<OPTION>ASAT</select></td>

</TR>
</TABLE>
</CENTER>

 
<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<tr><td ALIGN=CENTER>
<B>PRODUCT GROUP INFORMATION<B></TD></TR>
</TABLE>
</CENTER>

<P><P>
<CENTER>
<TABLE BORDER="1" WIDTH=600>

<TR>
<TD>TECH</TD><td><INPUT NAME="TECH" SIZE=15></td>
<TD>PRODFAM</TD><td><INPUT NAME="PRODFAM" SIZE=15></td>
</tr>

<tr>
<TD>FUNCTION</TD><td><INPUT NAME="FUNCTION" SIZE=15></td>
<TD>EXTFUNC</TD><td><INPUT NAME="EXTFUNC" SIZE=15></td>
</TR>

<TR>
<TD>PERFORM</TD><td><INPUT NAME="PERFORM" SIZE=15></td>
<TD>PIN</TD><td><INPUT NAME="PIN" SIZE=15></td>
</TR>

<TR>
<TD>PACKAGE</TD><td><INPUT NAME="PACKAGE" SIZE=15></td>
<TD>REL CLASS</TD><td><INPUT NAME="RELCLASS" SIZE=15></td>
<TD></TD>
</TR>
</TABLE>
</CENTER>

 
<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>
<TR><TH ALIGN=right VALIGN=top>Message:<TD><TEXTAREA NAME="body" COLS=40 ROWS=10 WRAP=virtual></TEXTAREA></TR>
</TABLE>
</CENTER>

</FORM>
<center>
<TABLE BORDER="0" WIDTH=600 CELL SPACING=0 CELL PADDING=0>

<FORM
  NAME="mailForm"
  ACTION="mailto:"
  METHOD="post"
  ENCTYPE="multipart/form-data"
  onSubmit="return mailIt(this)"
>
<INPUT TYPE="hidden" NAME="mailBody" VALUE="">
<TR>
<TD COLSPAN=2 ALIGN=center>
    <INPUT TYPE="submit" VALUE="Send This Mail Message Now" >
 </TR>
 </FORM>
</TABLE>
</center>
</BODY>
</HTML>
OK - if all you need is the "thanks", then there's an easier way ... rather than appending the document.location to the function, put it directly into the SUBMIT button, thus:

 <INPUT TYPE="submit" VALUE="Send This Mail Message Now" onClick="document.location='thankspage.html'">
once small correction, It should be
onClick="document.location.href='thankspage.html'".

I appreciate your help, Your total grade shows that your are a real pro.
Strange, It (thanks page) worked fine on Friday and now its not working. At times if i clear the cache and try it again, it works. Tried everything with no success, any suggesstions

<FORM
  NAME="mailForm"
  ACTION="mailto:"
  METHOD="post"
  ENCTYPE="multipart/form-data"
  onSubmit="return mailIt(this)">
<INPUT TYPE="hidden" NAME="mailBody" VALUE="">
<TR>
<TD COLSPAN=2 ALIGN=center>
<INPUT TYPE="submit" VALUE="Submit This SPEC Now" onClick="document.location.href='/msp/product/thanks.html'"></td>
</TR>
</FORM>