The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Undefined error with this javascript - help needed

I've tried to ammend a script to simply show the date a few days ahead. I came up with the following, but it shows the result as "28 Novemberundefined". I've spent ages, but can't get rid of the "undefined". Could somebody help please? Thank you.
<script>
<!-- hide from old browsers
months = "January,February,March,April,May,June,July,August,September,October,November,December".split(',')
;
daysInTheFuture=3;
function replyWhen() {
now = new Date();
aDayInMilliseconds = 24*60*60*1000;
then = new Date(now.getTime()+(daysInTheFuture*aDayInMilliseconds));
document.write(then.getDate() + " " + months[then.getMonth()])

Ignore that first example. That was not well thought out and would not work when you cross months. I believe this example is a better one and hopefully should help.
<html>
<head>
<title>Add to a date</title>
<SCRIPT LANGUAGE="JavaScript">
textmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
curdate=new Date()
curmonth=curdate.getMonth()
curday=curdate.getDate()
curhours=curdate.getHours()
curmins=curdate.getMinutes()
cursecs=curdate.getSeconds()
curmilsecs=curdate.getMilliseconds()
curyear=curdate.getFullYear()
function adddate(formid)
{
adddays=parseInt(formid.tdays.value) // number of hours to add
addhours=parseInt(formid.thours.value) // difference between GMT and Local time
temputc=Date.UTC(curyear,curmonth,curday+adddays,curhours+addhours,curmins,cursecs,curmilsecs)
newdate=new Date(temputc) // Create date object from milliseconds
newyear=newdate.getFullYear()
newmonth=newdate.getMonth()
newday=newdate.getDate()
formid.tdate.value=newday+" "+textmonth[newmonth]+" "+newyear
}
</SCRIPT>
</head>
<body>
<BR><BR>
<FORM NAME="myform">
Enter the number of days to add to the current date: <INPUT TYPE="text" size="4" NAME="tdays"><BR>
Enter the number of hours difference between GMT and Local time: <INPUT TYPE="text" SIZE="2" NAME="thours"><BR>
<INPUT TYPE="text" size="30" NAME="tdate">
<INPUT TYPE="button" VALUE="Get Date" onClick="adddate(this.form)">
</FORM>
</body>
</html>