Hello all,
i've got a bit of a problem. I've got a page where i would like users to enter the date in the first textbox (in the format dd/mm/yy) and then using javascript, automatically convert that date to format (Monday 7th May 2001).
I've got it to work to some degree, however, the weekday produced is inaccurate, so is the last day of the month and December.
Hope you can help.
Code is attached below, Jonathan
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<script language="javascript">
<!--display date-->
dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
dayNum = new Array ("1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th","10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th","31st"
monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
function convDate()
{
var strMainString= document.form1.txtDateNum.value; //date typed in 1st textbox
var year= strMainString.substring(6,10); //last four
var month= strMainString.substring(3,5); //middle two
var day= strMainString.substring(0,2); //first two
var test = new Date(year, month, day);
output=dayName[test.getDay()]+ " " +dayNum[test.getDate()-1]+" " +monName[test.getMonth()-1]+ " " +year;
document.form1.txtDateText.value=output;
}
</script>
</HEAD>
<BODY>
<form method=post action="update_wkact2.asp" name=form1 onSubmit="">
<center>
Date(dd/mm/yyyy):<input type="text" name="txtDateNum" size=15 onBlur=convDate()><br>
Date(in words): <input type="text" name="txtDateText" size=25 value=""><br>
Events:<textarea name="txtDaysEvents" rows="4" cols="40" wrap="no"></textarea><br>
<input type="submit" value="Submit">
</center>
</form>
</BODY>
</HTML>
i've got a bit of a problem. I've got a page where i would like users to enter the date in the first textbox (in the format dd/mm/yy) and then using javascript, automatically convert that date to format (Monday 7th May 2001).
I've got it to work to some degree, however, the weekday produced is inaccurate, so is the last day of the month and December.
Hope you can help.
Code is attached below, Jonathan
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<script language="javascript">
<!--display date-->
dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
dayNum = new Array ("1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th","10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th","31st"
monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
function convDate()
{
var strMainString= document.form1.txtDateNum.value; //date typed in 1st textbox
var year= strMainString.substring(6,10); //last four
var month= strMainString.substring(3,5); //middle two
var day= strMainString.substring(0,2); //first two
var test = new Date(year, month, day);
output=dayName[test.getDay()]+ " " +dayNum[test.getDate()-1]+" " +monName[test.getMonth()-1]+ " " +year;
document.form1.txtDateText.value=output;
}
</script>
</HEAD>
<BODY>
<form method=post action="update_wkact2.asp" name=form1 onSubmit="">
<center>
Date(dd/mm/yyyy):<input type="text" name="txtDateNum" size=15 onBlur=convDate()><br>
Date(in words): <input type="text" name="txtDateText" size=25 value=""><br>
Events:<textarea name="txtDaysEvents" rows="4" cols="40" wrap="no"></textarea><br>
<input type="submit" value="Submit">
</center>
</form>
</BODY>
</HTML>