Skip to main content
Inspiring
November 22, 2011
Pregunta

date picker. user selects a start date click radio button then give an end date

  • November 22, 2011
  • 1 respuesta
  • 6418 visualizaciones

i have seen the widget for date picker that works great but i need another function.

Once the user selects that date (their start date from the date picker) underneath this there are 2 radio buttons one for 43 weeks and one for 52 weeks. I need that once the required "weeks" is selected a feild underneath is populated with a new date adding either 43 or 52 weeks to the start date.

php mysql used

i think this is done using javascript

if there is another way less complicated to do it i would live to know

thanks

Este tema ha sido cerrado para respuestas.

1 respuesta

Community Expert
November 22, 2011

I'm not a big javascript person myself, so what I would do is allow them to select the start date with the date picker and a radio button for the weeks like you did.  Then I would run a confirmation page instead of submitting instantly and calculate the end date on the next page using the PHP strtotime function ( http://php.net/manual/en/function.strtotime.php ) to get a date and then put that into the database if they choose to accept the confirmation. 

Here's an example of what I'm talking about: http://www.brightcherry.co.uk/scribbles/2009/01/06/php-adding-and-subtracting-dates/

Inspiring
November 22, 2011

what so you mean make a comfirmation page for the whole form that includes the date picker date and the radio button result then when they go to the next (confirmation page) this will calculate the end date?

Community Expert
November 23, 2011

Jonathan Fortis wrote:

what so you mean make a comfirmation page for the whole form that includes the date picker date and the radio button result then when they go to the next (confirmation page) this will calculate the end date?

No the confirmation page won't have the date picker.  The submission form will have the date picker, then you store the variables in a session, display a confirmation page for the users to verify the infromation and say something like: "43 Week Plan - Next Renewal 8/23/12".

Or here's something else I came across.  Looks to be what you are looking for with JQuery populating a hidden field:

http://stackoverflow.com/questions/3813973/jquery-ui-datepicker-add-days

I should add that's for the JQuery UI Datepicker:

http://jqueryui.com/demos/datepicker/