View Single Post
Old 10-04-2012, 12:38 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Working too hard.
Code:
<!DOCTYPE html>
<html>
<body>
<form id="frm">
<select name="dropdown">
<option value="0">Select a Date</option>
<option value="15">15 Days from Now</option>
<option value="30">30 Days from Now</option>
<option value="45">45 Days from Now</option>
<option value="60">60 Days from Now</option>
</select>
<input type="text" name="mytext" size=60>
</form>
<script type="text/javascript">
(
  function( )
  {
      var form = document.getElementById("frm");
      var mytextbox = form.mytext;
      var mydropdown = form.dropdown;
      mydropdown.onchange = 
          function( )
          {
             var theDate = new Date();
             theDate.setDate( theDate.getDate() + Number(this.value) );
             var pretty = (theDate.getMonth()+1) + "/" + theDate.getDate() + "/" + theDate.getFullYear();
             mytextbox.value = pretty;
          }
  }
)( );
</script>
</body>
</html>
Change the code for pretty to format the date however you want it.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote