View Single Post
Old 10-03-2012, 11:51 PM   PM User | #1
drameller
New to the CF scene

 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
drameller is an unknown quantity at this point
Adding days to today’s date

I have a script I pieced together from this forum and have hit a wall so to speak—I was hoping I could get some input. I wish to have a dropdown menu containing date options (15 days, 30 days, 45 days, 60 days…) When a selection is made, a text field appears next to your selection containing the difference in your selection vs the current date. So for example. If today was January 1st, and you selected 30 days, the box would show Jan 31st. I’ve managed to make this work for only the first date selection option, any other date selection shows the result for the first option only. Ultimately what I would like it to list the corresponding date given the 15/30/45/60 day selection.Hoping I could get some assistance. Thank you very much!

Code:
<BODY onload="init()">
<script language="JavaScript"><!--
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);
}
//--></script>

<form name="frm" id="frm">
<select id="dropdown">
<option value="None">Select a Date</option>
<option value="text1">15 Days from Now</option>
<option value="text2">30 Days from Now</option>
<option value="text3">45 Days from Now</option>
<option value="text3">60 Days from Now</option>

</select>
<input type="text" id="mytext" size=60>
</form>
</BODY>
</HTML>

<script type="text/javascript">
var mytextbox = document.getElementById('mytext');
var mydropdown = document.getElementById('dropdown');

mydropdown.onchange = function(){
mytextbox.value= addDays(new Date(),+15);
}
</script>
drameller is offline   Reply With Quote