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

attempting to add 7 days to a date real time

Status
Not open for further replies.

ericaalicen

Programmer
Dec 20, 2001
53
US
I need to take a starting date entered in a form field and add 7 days and display that in the form field for an ending date. I'm not especially javascript savvy. I've put together a script from a number of different things I've found on line, but the ending date always appears as 0.

<script>
function add(theForm) {
var start = form.start.value;
if (!isNaN(start)) {
var x = setDate(start.getDate() + 7);
form.end.value = x;
}
}
</script>
<form name=&quot;form&quot; method=&quot;post&quot; action=&quot;avail.cfm?add=1&quot;>
Start: <input type=&quot;text&quot; name=&quot;start&quot; size=&quot;10 onKeyUp=&quot;add(this.form)&quot;>   
End: <input type=&quot;text&quot; name=&quot;end&quot; size=&quot;10&quot;>   
Price: <input type=&quot;text&quot; name=&quot;price&quot; size=&quot;10&quot;>   
<input type=&quot;submit&quot; value=&quot;Add&quot;> </form>

Any help is appreciated.
 

there's a little more to date calculations in javascript then jsut adding the number unfortunetly

take a look at the tutorial in the link. should get you going ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top