Skip to main content
Inspiring
November 22, 2011
Question

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

  • November 22, 2011
  • 1 reply
  • 6418 views

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

This topic has been closed for replies.

1 reply

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?

Inspiring
November 24, 2011

Going back to this post you are missing the includes in that page.  Take a look at the source of the example page:

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

The files have to be included in the head before the javascript is run.  And they have to be called in a particular order jquery->jqueryui->datepicker.  Also for the code the #arrivalDate and so on, will need to be updated to match your form.  The #arrivalDate notes the ID that is being called from your form.  In this person's example the #arrivalDate is where their datepicker is setup.

I can try to set up an example page but with the holiday I might not be able to put more time into it until the end of the weekend or early next week.


ok thanks, i will try and do as much as i can today / tonight and will see how i get on.

I post what it acheive, thanks