Hi,
I have written some code that is nearly doing what i want by adding 365 days to a user defined date but it is treating my date as US format not UK so it's coming up with the wrong result.
Could someone look at it and tell me what i'm doing wrong please? Thanks in advance.
I have written some code that is nearly doing what i want by adding 365 days to a user defined date but it is treating my date as US format not UK so it's coming up with the wrong result.
Could someone look at it and tell me what i'm doing wrong please? Thanks in advance.
Code:
<html>
<head>
<script language=JavaScript>
function adddate(){
var cur_priority = "Low";
var last_hs = document.forms[0]._last_hs.value;
var daystoadd = 0;
if (cur_priority == "High"){
daystoadd = 91;
}
else if (cur_priority == "Medium"){
daystoadd = 182;
}
else if (cur_priority == "Low"){
daystoadd = 365;
}
alert(cur_priority);
alert(daystoadd);
var d = new Date(last_hs);
d.setDate(d.getDate()+daystoadd);
alert(d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getYear());
document.forms[0]._next_hs.value = d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getYear()
}
</script>
</head>
<body>
<form name=form1>
<table>
<tr><td class=ContactBoldText>Last_HS</td>
<td class=ContactBoldText><input type="text" name=_last_hs value="15/06/2011"></td></tr>
<tr><td class=ContactBoldText>next_HS </td>
<td class=ContactBoldText><input type="text" name=_next_hs ></td></tr>
<tr><td><input type=button onclick="adddate()" value=click> </td></tr>
</table>
</form>
</body
</html>