CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Button to write actual time/date to textbox

Print topic Send  topic

Author Message
jensotten
Posted: 11/27/2002, 3:34 AM

Hi,
I think this is a real simple question, but I am not very familiar with JScript etc.

I am using CC Studio. To edit a record, i have created a maintain-page, where all fields can be updated. There is a textbox named "offdate" and a corresponding button.
When pressing this button, the actual date should be written into this textbox.

How can I implement this ?
Is there a CC standard function for this purpose ?

Thanks for any advice.

Jens
MikeL
Posted: 11/27/2002, 5:28 AM

Add a button from the forms tab of the toolbox. Switch to html view. Find the code for your button and add the onclick event like this example:

<!-- BEGIN Button TimeStamp --><input type="button" value="TimeStamp" name="TimeStamp" onclick="now = new Date(); document.<form name>.<field name>.value = document.<form name>.<field name>.value + now.getDate() + '/' + now.getMonth() + '/' + now.getYear() + ' ' + now.getHours() + ':'+ now.getMinutes() + ':'+ now.getSeconds() + '\n\r';"><!-- END Button TimeStamp -->

This example actually appends the date (and time) in a text area followed by a carriage return. If you just need the current date try this:

<!-- BEGIN Button TimeStamp --><input type="button" value="TimeStamp" name="TimeStamp" onclick="now = new Date(); document.<form name>.<field name>.value = now.getDate() + '/' + now.getMonth() + '/' + now.getYear();"><!-- END Button TimeStamp -->

Of course you can rearrange the date format to fit your needs, ie. this example uses dd/mm/yyyy. To get yyyy/mm/dd rearrange the string
now.getYear() + '/' + now.getMonth() + '/' + now.getDate()
jensotten
Posted: 11/28/2002, 8:46 AM

Hi Mike,
I tried different code, but no success.

The button name is Button1, the formname is T_Besucherd, the textboxname is endedatum.
What is wrong with the code ?


<!-- BEGIN Button Button1 --><input type="button" value="Button1" name="Button1" onclick="now = new Date(); document.T_Besucherd.endedatum.value = now.getDate() + '/' + now.getMonth() + '/' + now.getYear();"><!-- END Button Button1 -->
jensotten
Posted: 12/01/2002, 5:55 AM

Really no idea ?

Please help.

Jens
Carey
Posted: 12/01/2002, 6:23 AM

Try this:

<INPUT ID="Button2" TYPE="button" VALUE="Button2" NAME="Button2" ONCLICK="now = new Date(); document.T_Besucherd.endedatum.value = now.getDate() + '/' + now.getMonth() + '/' + now.getYear();">

You can change the "Button2" to anything...I just tried it and it works great.

Carey

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.