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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Mail with Date in Subject Line 1

Status
Not open for further replies.

GummowN

Programmer
Jul 26, 2002
157
GB
I know next to nothing about JS but would love a bit of help to overcome a small problem

Currently

mailto:thursday_footy@footylist.info?subject=Footy: Thursday dd-mmm-yyyy&body=Update dd-mmm-yyyy above and send this with a short message, if you wish. Note: if you're not already registered with us, please use the 'Register Your Interest' link on our homepage. Please also mention if you're wanting to take part in a lunchtime game

All I want to do is replace dd-mmm-yyyy with the next Thursdays date?

Any suggestions - and be gentle

If at first you don't succeed, try for the answer.
 
suggest that you change the mailto into a function call that can build up the link inside the function and then call it.

e.g.

<a href="javascript:sendMail()">send an email</a>

<script language="javascript" type="text/javascript">
function sendMail()
{
var theDate=new Date();
var dayToday=theDate.getDay();
var months=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var dateString="";

// check which day we have
// if less than Thursday
if (dayToday<4)
{
// add the days missing
theDate.setDate(parseInt(theDate.getDate()) + (4-parseInt(dayToday)))
}
else if (dayToday>4)
{
// add the days missing
theDate.setDate(parseInt(theDate.getDate()) + (7-parseInt(dayToday-4)))
}

// build the data string to put in the email
dateString=theDate.getDate() + "-" + months[theDate.getMonth()] + "-"+ theDate.getFullYear();

var mailString="thursday_footy@footylist.info?subject=Footy: Thursday " + dateString + "&body=Update " + dateString + " above and send this with a short message, if you wish. Note: if you're not already registered with us, please use the 'Register Your Interest' link on our homepage. Please also mention if you're wanting to take part in a lunchtime game"

document.location="mailto:" + mailString;
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top