Matt Harrison wrote:
> One of my apps is using the calendar date select plugin[1] to let users
> select the start and end date for an event.
>
> The app is in beta and so far the users have asked if I can do this:
>
> When the start date is selected, they want the end date to duplicate the
> start. Then if it is a single day event, they can just leave the end
> date, or if it is a multi-day event they can change it.
>
> Obviously this is client-side and will probably need some javascript but
> that isn't my strong point and considering the relative complexity of
> the calendar helper, I have no idea where to start.
>
> Any advice on this gratefully received. If I haven't explained this
> clearly enough please let me know and I will try to clarify.
>
> Thanks
>
> Matt
>
> [1]http://code.google.com/p/calendardateselect/
The quick & dirty way is something like this...
1. Add an onchange event handler to the start date field to call a JS
function.
onchange="copy_start_to_end();"
2. Write the JS function, either in application.js or in your view.
Something like this:
function copy_start_to_end() {
if ($F('end_date').blank()) { // only copy start if end is blank
$('end_date').value = $F('start_date');
}
}
I haven't tested it, but this should be pretty close. This assumes
you're using Prototype JS.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---