Jump to content

Automatically enter today's date


Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.