Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Auto-populate the days of the week from a single field

$
0
0

I am trying to add a script that will auto-populate the days of the week from a single field. I've got a sample script that will populate the fields from today's date, but that is not what i'm looking for. I need the date to populate from a previous date which is entered from a separate field. Any help is appreciated.

 

Here is the script I've pirated:

var today = new Date() ;

this.getField("sun").value = util.printd("mm/dd/yyyy", today) ; // fills field for today

this.getField("mon").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+1)) ; // fills field for  monday

this.getField("tue").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+2)) ; // fills field for tuesday

this.getField("wed").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+3)) ; // fills field for wednesday

this.getField("thu").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+4)) ; // fills field for  thursday

this.getField("fri").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+5)) ; // fills field for friday

this.getField("sat").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+6)) ; // fills field for saturday

 

I know enough to be dangerous - then again maybe I don't.

 

Thanks for your help.

~C


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>