Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some help please. Add Days to Date

Status
Not open for further replies.

esurge

Programmer
Jun 15, 2004
8
NL
Hello

I need some reall help please.

Ok I have 3 fields

1 = name="x_start_date"
2 = name="x_no_day_count"
3 = name="x_end_date"

Right.


I need a Script that when i put the start_date in and the no_days_count it will automaticaly work out the end date.

Can anyone point me in the right direction.

Jazz
 
Code:
<html>
<script>
function CheckDate()
{
    dt=document.FormName.TheTextField.value
    dt=dt.split("/")
    datField=new Date()

    dd=parseInt(dt[1])//The Textbox Date
    mm=parseInt(dt[0])//The Textbox Month
    yy=parseInt(dt[2])//The Textbox Year

    datField.setDate(dd)
    datField.setMonth(mm-1)
    datField.setYear(yy)


    dat=new Date()

    addnum=parseInt(document.FormName.AddDay.value)
    dat.setDate(dat.getDate()+addnum)
    document.FormName.Result.value=dat
}
</script>
<form name="FormName">
<input type="text" value="7/26/2004" name="TheTextField" >
<input type="text" value="10" name="AddDay" >
<input type="text" value="" name="Result" >
<input type="button" name="b1" value="Click" onclick="CheckDate()">
</form>
</html>

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top