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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript date object/increment notes field

Status
Not open for further replies.

DoctorGonzo

Programmer
Jan 23, 2004
48
0
0
GB
Hi guys,

similar topics have been covered before, but none have helped me really.

I simply want to prompt user with "number of days", and whatever the user types in is captured. A date object on the field is then incremented with/by this number. No matter what I do I get "object does not support this property or method". Bah! I'm used to this message! :)

Anyway, can anyone please help me with this code?

Many thanks,

Gonzo

function ExtendTheDate(){
var dateday = prompt("Please enter number of days to increase expiry date by","")
if (dateday != null && dateday != "")
{
alert("This Will increase date object by " + dateday + " days!");
document.forms[0].DateToChange.setDate(document.forms[0].DateToChange.getDate()+ dateday);
}
 
I'm a bit out of practice with JS, so I can't really help, but I'm guessing your problem is with this line:

document.forms[0].DateToChange.setDate(document.forms[0].DateToChange.getDate()+ dateday);

Use comments and a process of elimination to determine if this is truly the source of your problems, and if it is, try this instead:

var inc = document.forms[0].DateToChange.getDate()+ dateday
document.forms[0].DateToChange.setDate(inc);

Just an idea - putting things in variables sometimes solves little glitches like this. Sorry if its no help, but I tried! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top