Hi,
I have been trying to build a script to take a date that is going to be manually entered in to a text field and based on the selection from a dropdown add x amount of days to the date and display the value in the text field.
Well I’m ready to pull my hair out now as I have tried everything and was wondering if anyone could look at my code and point me in the right direction.
Thanks for looking
I have been trying to build a script to take a date that is going to be manually entered in to a text field and based on the selection from a dropdown add x amount of days to the date and display the value in the text field.
Well I’m ready to pull my hair out now as I have tried everything and was wondering if anyone could look at my code and point me in the right direction.
Thanks for looking
Code:
<html>
<head>
<script language="JavaScript">
<!--
//Get todays date in a format for the function below (poject start dates)
var d=new Date()
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
//Takes the sales Stage and calulates the dates based on the stage.
function function1(Sales_Stage) {
var Sales_Stage_value = (Sales_Stage.options[Sales_Stage.selectedIndex].text);
//alert("Sales_Stage_value")
if (Sales_Stage_value == "ASSESSED") {
d.setDate(d.getDate()+4)
document.forms[0]._course_start_date.value = d.getDay()+'/'+d.getMonth()+'/'+d.getYear()
}
else if (Sales_Stage_value == "PLANNED") {
d.setDate(d.getDate()+7)
document.forms[0]._course_start_date.value = d.getDay()+'/'+d.getMonth()+'/'+d.getYear()
}
else if (Sales_Stage_value == "ACTIVE") {
d.setDate(d.getDate()+5)
document.forms[0]._course_start_date.value = d.getDay()+'/'+d.getMonth()+'/'+d.getYear()
}
// else if (Sales_Stage == "") {
// document.forms[0]._date.value = day+"/"+month+"/"+year
// }
}
-->
</script>
</head>
<body>
<form>
<Select name="Sales_Stage" onChange="function1(Sales_Stage)">
<option></option>
<option>ACTIVE</option>
<option>PLANNED</option>
<option>ASSESSED</option>
</selecT>
<input type="text" name="_course_start_date" value="01/10/2009" />
</form>
</body>
</html>