Jump to content


Photo

Automatically enter today's date


  • Please log in to reply
4 replies to this topic

#1 Colleen

Colleen
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 28 September 2004 - 03:43 PM

I have a form that has a group of 4 radio buttons named "Status". I would like to have today's date automatically entered into a field ("DateWonorLost") when the radio button "Won" is clicked (the won button has a value of 2). I have been experimenting with onClick, but am not making any progress. Does someone have any guidance for me? Sample code?

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 28 September 2004 - 03:49 PM

Dumb question: why not have the date in that field whether they click won, click lost, or do nothing? That way you can populate the field using php server-side, rather than relying on client-side javascript (which might not necessarily be active).

Actual php code will vary depending on what date format you want in the field.
Legend has it that reading the manual never killed anyone.
My site

#3 Colleen

Colleen
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 28 September 2004 - 04:14 PM

Okay, so if I want to have the date automatically entered into the field when any of the four radio buttons are clicked, how would I go about that? The format of the date will be mm/dd/yyyy.

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 28 September 2004 - 05:35 PM

<input type="hidden" name="DateWonorLost" value='<?php echo date("m/d/Y"); ?>' />
That will populate the field whenever the form is displayed. If you only want that field to be populated when a radio button is clicked, you'll have no option but to do it with javascript OR have the form resubmit itself. Maybe that'll help
Legend has it that reading the manual never killed anyone.
My site

#5 Colleen

Colleen
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 October 2004 - 09:53 PM

Thanks for your reply, I used your code on one form, but not on another.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users