Compute Date set Time from Choice Date

[Total: 0    Average: 0/5]

This example shows how to have a date computed from a select menu choice of a date.

Body Code:

<script language="javascript" type="text/javascript">
function go(){ 
 var date  = document.f1._date[document.f1._date.selectedIndex].value;
 var month = document.f1._month[document.f1._month.selectedIndex].value; 
 var year  = document.f1._year[document.f1._year.selectedIndex].value; 
 var startDate = new Date(); 
 var nextDate = new Date(); 
 nextDate.setTime(startDate.getTime() + 28 * 24 * 60 * 60 * 1000); 
 alert("startDate: " + startDate + "nnextDate: " + nextDate); 

<form name="f1">
<select name="_date">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
<select name="_month">
  <option value="0">January</option>
  <option value="9">October</option>
  <option value="10">November</option>
<select name="_year">
  <option value="2000">2000</option>

<p><input type="button" value="Calculate 28 days from today." onclick="go()"></p>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *