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!

Hello, I need help with a date

Status
Not open for further replies.

nalbiso

Programmer
Aug 31, 2000
71
0
0
US
Hello,

I need help with a date processing function. I have a form where my customers will put in a date (in format mm/dd/yy). But I want that date to be used to update another field on the form with just the day of the week only.

I've tried this:

Code:
<script type=&quot;text/javascript&quot;>
var d=new Date()
var weekday=new Array(&quot;Sunday&quot;,&quot;Monday&quot;,
              &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;,
              &quot;Friday&quot;,&quot;Saturday&quot;)
</script>

And then calling the following the following during an onblur:
Code:
document.estform.startingdayofweek.value=weekday[d.getDay(document.estform.startdate.value)]

But this just keeps returning today's weekday in the startingdayofweek textbox.

Can someone please let me know what I am doing wrong here or if there is a more efficient way to do this, please let me know?

Thanks!
 
This is a javascript question. not CF
second you set d = todays date (date()) then reference d.
try.
document.estform.startingdayofweek.value=weekday[document.estform.startdate.value.getDay()]

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
- Quote by Douglas Adams
 
or better yet
document.estform.startingdayofweek.value=weekday[this.value.getDay()]

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
- Quote by Douglas Adams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top