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!

Poping A Date Into A Text Box 1

Status
Not open for further replies.

Hackster

Programmer
Mar 28, 2001
173
US
I'm sure this is a pathetically easy question, but my sum total Cold Fusion experience is 3 days. I have two radio buttons and a text box on my form. I know I can use the Now() function to get today's date (and I assume that Now()-1 will get me yesterdays date). My question is: When the user clicks the Today option button, how do I get the current day to pop into the correct text box? (PS: I have order "Cold Fusion for Dummies", but it hasn't arrived yet.)
 
Hey Hackster

Not Exactly a beginner move but sounds like fun. That will require Javascript and CF. This example will append todays date on the end of the text in the form field named "Date", you could easily make it write over the contents with todays date but this looked like more fun.

Code:
<CFOUTPUT>
<SCRIPT Language=&quot;JavaScript&quot;>
  <!--

    function popdate(form)
    {
      form.Date.value = form.Date.value + &quot;#DateFormat(Now(),'MM/DD/YYYY')#&quot; ; 
    }
//-->
</script>
</CFOUTPUT>

<FORM METHOD=&quot;POST&quot; ACTION=&quot;TestDatepop.cfm&quot; NAME=&quot;myform&quot;>
<input type=&quot;button&quot; value=&quot;Today&quot; OnClick=&quot;popdate(this.form)&quot;>
Date: <input type=&quot;text&quot; Name=&quot;Date&quot;>
</FORM>
[code]

Strangely enough Now()-1 works for yesterday.  I wasn't sure about that.  Sounds like you're off to a good start, by the way, you're probably going to want a better book in a few days. :)  

I hope your CF programming is successful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top