View Single Post
Old 10-12-2012, 05:17 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Perhaps a simpler solution.

Code:
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>

<select id = "priority" onchange = "calcdeadline()">
<option value = 0>Select priority level...</option>
<option value = 1>1 hour</option>
<option value = 4>4 hours</option>
<option value = 24>24 hours</option>
<option value = 168>7 days</option>
<option value = 720>30 days</option>
</select>

<input type = "text" id = "deadline" size = 60 readonly>

<script type = "text/javascript">

function calcdeadline()  {
var myDate=new Date();
var val = Number(document.getElementById("priority").value);  // from dropdown
myDate.setHours(myDate.getHours()+val);
document.getElementById('deadline').value=myDate;
}

</script>

</body>
</html>
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote