Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing data from javascript var to html

Status
Not open for further replies.

geuis

Programmer
Jan 26, 2003
7
US
I am trying to write some code that will create a new mail message when clicked on, but will include the time of creation in the body of the message. I am *not* trying to get it to auto-send. I still need to be able to make changes to the email if necessary, then manually send it.

Code I have so far makes the message w/ To: and Subject:
<a href=&quot;mailto:anyone@anywhere.com?subject=&quot;a Simple Email&quot;>Dropped Call</a>

Problem is that I can generate the current time in a simple javascript function, but I don't know how to put that time, stored in var curTime into the body of the email automatically. Any help is much, much appreciated.
 
<script>
function hrefMail(objHref){
dteNow = new Date();
objHref.href='mailto:anyone@anywhere.com?Subject=a Simple Email on ' + dteNow.toString();
}
</script>
<a href='' onClick='hrefMail(this)''>send mail</a>
 
This works with an outlook mail client. Don't know for other mail clients :
Code:
<script language=&quot;javascript&quot;>
function sendEmail() {
  var o_Date = new Date();
  var o_link=document.getElementById(&quot;MailLink&quot;);
  var mailUrl = &quot;mailto:anyone@anywhere.com?subject=a Simple Email&body=&quot; + o_Date.toLocaleDateString();
  o_link.href = mailUrl;
}
</script>
<a id=&quot;MailLink&quot; href=&quot;&quot; onclick=&quot;sendEmail();&quot;>Dropped Call</a>
Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top